Git Product home page Git Product logo

Comments (3)

Clivern avatar Clivern commented on June 5, 2024

I am not an expert with flutter but from the error Connection to http[s]:// $$$$' was not upgraded to websocket, it seems your code still doing HTTP connection & need to upgrade to webSockets. I think it can be done by sending these headers

Connection: Upgrade
Upgrade: websocket

As explained here https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism#Upgrading_to_a_WebSocket_connection

I checked this website wss://echo.websocket.org/ and i see these header in the request & server response so maybe we have to add these headers in beaver response if sending the headers solely won't help. so pls let me know!

Screen Shot 2020-12-29 at 7 26 47 PM

from beaver.

Abdelrhman9623 avatar Abdelrhman9623 commented on June 5, 2024

IOWebSocketChannel.connect('wss://go-beaver-k8s-1.nimi24.com/',
headers: {
'token': '',
'Connection': 'Upgrade',
'Upgrade': 'websocket',
}),
the same issue
I/flutter ( 3355): AsyncSnapshot(ConnectionState.done, null, WebSocketChannelException: WebSocketChannelException: WebSocketException: Connection to 'https://go-beaver-k8s-1.nimi24.com:0/#' was not upgraded to websocket)

from beaver.

Clivern avatar Clivern commented on June 5, 2024

Well that's interesting because beaver already add these headers https://github.com/gorilla/websocket/blob/c3dd95aea9779669bb3daafbd84ee0530c8ce1c1/server.go#L217

I just tested that.

What is the URL y use to connect as a client, it should be something like
wss://go-beaver-k8s-1.nimi24.com/ws/$$CLIENT_ID$$/$$CLIENT_TOKEN$$

so i assume you use IOWebSocketChannel.connect('wss://go-beaver-k8s-1.nimi24.com/ws/~client-id~/~client-token~',?
token not need in headers actually

and to create a client id and token

$ curl -X POST \
    -H 'Content-Type: application/json' \
    -H 'X-AUTH-TOKEN: YOUR-API-TOKEN-HERE' \
    -d '{"channels": []}' \
    'https://go-beaver-k8s-1.nimi24.com/api/client'

{
  "channels": [],
  "created_at": 1609269864,
  "id": "0de46431-af57-4768-8d2d-14b8c07a1f0b",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiMGRlNDY0MzEtYWY1Ny00NzY4LThkMmQtMTRiOGMwN2ExZjBiQDE2MDkyNjk4NjQiLCJ0aW1lc3RhbXAiOjE2MDkyNjk4NjR9.1vNZ20Ehj-OeFDPIF21QN84a-mip4F5ZMTKLahvk1iw",
  "updated_at": 1609269864
}

I am trying to know if it is issue with flutter or not. so can you try to init a websocket from browser > inspect > Console, don't forget to replace client id and token.

function Socket(url){
    ws = new WebSocket(url);
    ws.onmessage = function(e) { console.log(e); };
    ws.onclose = function(){
        // Try to reconnect in 5 seconds
        setTimeout(function(){Socket(url)}, 5000);
    };
}

Socket('wss://go-beaver-k8s-1.nimi24.com/ws/~client-id~/~client-token~');

UPDATE: that didn't help, same issue on flutter repo https://github.com/flutter/flutter/issues?q=Connection+to+was+not+upgraded+to+websocket+

from beaver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.