Comments (3)
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!
from beaver.
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.
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)
- CORS headers middleware HOT 3
- Beaver v2 HOT 1
- Flutter support HOT 2
- Refactor util package
- Refactor modules package
- Add Test Benchmarks HOT 1
- Replace legacy logger HOT 3
- Update Docs
- Why was it sent to the client twice? HOT 2
- Action Required: Fix Renovate Configuration
- from_client is null HOT 2
- Dependency Dashboard
- Can not recieve message from subscribed channel HOT 1
- Go Client for beaver HOT 1
- I have some questions about this library HOT 1
- Don't handle error when create file log HOT 3
- Please explain config API routes /api/config/* HOT 1
- It panic error occasionally HOT 1
- Enhance beaver skelton to adapt new features
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from beaver.