Comments (5)
And I have not seen anything related to how to send it from the client side either.
from web_socket_channel.
And I have not seen anything related to how to send it from the client side either.
You send it using the IOWebSocketChannel's pingInterval property:
var channel =
IOWebSocketChannel.connect('url_goes_here', pingInterval: Duration(seconds: 10));
The client will send a ping every 10 seconds, and wait for a 'pong' back from the server.
Documentation doesn't explain how to respond to ping event on server side.
ws.pong() and ws.send('pong) didn't work.
The library automatically responds to server ping events, no configuration is needed for that. It's part of the RFC 6455 spec.
from web_socket_channel.
Documentation doesn't explain how to respond to ping event on server side.
ws.pong() and ws.send('pong) didn't work.The library automatically responds to server ping events, no configuration is needed for that. It's part of the RFC 6455 spec.
@mhstoller I am hoping you could shed some more light on the automatic response to server ping events.
We have a node WebSocket server that is using the RFC 6455 spec and sends a ping
every 30 seconds to our flutter app.
The flutter app is connecting to the WebSocket server like this example below.
var channel =
IOWebSocketChannel.connect('url_goes_here', pingInterval: Duration(seconds: 15));
The server never receives a pong
response and subsequently closes the WebSocket connection.
Can you point me to any documentation or where in the library the automatic response happens?
Should the server be expecting something besides pong
in response?
from web_socket_channel.
@brax10ward so coming back to this a year later I don't want to dig through the code, but I did a cursory look and there's code like this:
case _WebSocketOpcode.PING:
_eventSink!.add(_WebSocketPing());
break;
case _WebSocketOpcode.PONG:
_eventSink!.add(_WebSocketPong());
break;
I would guess that it responds to ping events with a ping of its own. With it being part of the spec though I would assume it's something that can be handled in the node library you are using without much work on your end.
That said, I was trying to set something similar up for my own connections and you can read what I ended up doing in the comments here: #124
from web_socket_channel.
I think that is transforming a Ping opcode on the wire into a Ping event in the application code.
The section we are looking for is
web_socket_impl.dart:L724
from web_socket_channel.
Related Issues (20)
- Specifying 'protocols' (Sec-WebSocket-Protocol header) causes connection to close.
- HTML: When the WebSocket is in a 'pending' state, calling channel.sink.close does not work. HOT 2
- Masking is not cryptographically secure HOT 1
- I tried to connect with localhost 8081 port but its connect with diffrent port HOT 2
- FormatException: Unexpected character
- Simplify the web_socket_channel implementation HOT 5
- Message received in wrong order
- Support MSGPACK HOT 1
- Any problems with WebSocketChannel.connect under iOS 17.5 beta (or earlier)? HOT 3
- 🐛 RangeError (code): Invalid value: Not in inclusive range 3000..4999: 1000 after updating to 3.0.0 from 2.4.0 HOT 6
- Missing tags for 2.4.5 and 3.0.0
- Conflict package build_runner versions HOT 1
- Documentation for the 3.x migration HOT 12
- Unexpected Behavior and Premature Closure when Using web_socket_channel to Connect to WebSocket Server HOT 2
- WebSocket clients using Apple private relay can't connect to WebSocket server
- WebSocketChannel has unexpected close code
- WebSocketChannel close code throws exception
- There is not way to get acknowledgement of sent messages. HOT 1
- WebSocket support custom sni host,when use doh HOT 1
- Should the `ready` future fail if the socket gets closed while not resolved?
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 web_socket_channel.