-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Premature close? #5
Comments
|
Side note: no retry/reconnect option? |
Thank you for the issue. https://tools.ietf.org/html/rfc6455#section-5.5.2 I should support to return pong in this library when the client got a ping. |
I made a mistake. |
I saw no pong() method in the API, or I would have returned it in the on('ping', ... handler myself 👍 I can look at the other API, but this is going to be the preferred one for most people, I think. |
Yes, there is not pong() method in deno std ws library too. Can you try the following code? import {
connectWebSocket,
isWebSocketCloseEvent,
isWebSocketPingEvent,
isWebSocketPongEvent,
} from "https://deno.land/std@0.66.0/ws/mod.ts";
import { encode } from "https://deno.land/std@0.66.0/encoding/utf8.ts";
import { BufReader } from "https://deno.land/std@0.66.0/io/bufio.ts";
import { TextProtoReader } from "https://deno.land/std@0.66.0/textproto/mod.ts";
import { blue, green, red, yellow } from "https://deno.land/std@0.66.0/fmt/colors.ts";
const endpoint = "ws://hubitat/eventsocket";
/** simple websocket cli */
const sock = await connectWebSocket(endpoint);
console.log(green("ws connected! (type 'close' to quit)"));
for await (const msg of sock) {
if (typeof msg === "string") {
console.log(yellow(`< ${msg}`));
} else if (isWebSocketPingEvent(msg)) {
console.log(blue("< ping"));
} else if (isWebSocketPongEvent(msg)) {
console.log(blue("< pong"));
} else if (isWebSocketCloseEvent(msg)) {
console.log(red(`closed: code=${msg.code}, reason=${msg.reason}`));
}
} |
This is using deno in a docker container. Using the code in the previous comment as you requested. Dockerfile:
|
Also, I have deno installed natively in WSL2/Arch Linux and it errors if I try to deno upgrade. |
Your code runs in deno installed natively on my iMac. Same failure :(
|
Thank you for running the code. The following error is the problem that is a low layer.
I recommend that you should open an issue in the deno repository. |
Done. |
@mschwartz Released v1.4 |
Should be closed due to inactivity |
I am porting a server application from Node to Deno and the WebSocket behavior is unexpected.
The simplest program I've tried opens a WebSocket and prints messages received via on('message'...).
The connection is being made to a hubitat home automation controller. The hubitat periodically sends a message over the WebSocket and those are printed. After about 2-3 minutes, the on('close' method is called and there are no more messages received.
I have an on('ping' callback installed and it seems that is being called immediately before the close.
The error passed to close callback is 1002, which is socket closed, I believe.
I am thinking that maybe your client/server talk to each other without fail, but you client doesn't talk to existing and well tested servers? Hubitat software is Java based.
The text was updated successfully, but these errors were encountered: