Skip to content
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

Support PING / PONG messages #2

Closed
endel opened this issue Jun 14, 2018 · 2 comments
Closed

Support PING / PONG messages #2

endel opened this issue Jun 14, 2018 · 2 comments

Comments

@endel
Copy link
Contributor

endel commented Jun 14, 2018

Hey @britzl,

I'm trying to allow your library to respond to PING messages. It seems some PING messages aren't received sometimes.

So far, I've found that when the PING comes, it can be received here, and sometimes it doesn't:

local chunk,err = self:sock_receive(bytes)

I've added a check for opcode == 0x9 here to automatically send the PONG messages:

if opcode == 0x9 then
    -- reply PING opcode with PONG
    print("REPLY WITH PONG")
    self.send(self, message, 0xA)
elseif message then
    on_message(message)
end

My server logs are looking like this (Colyseus automatically disconnects users after 3 PING's without response 😢 )

SEND PING
SEND PING
PONG RECEIVED!
SEND PING
SEND PING
SEND PING

Do you have any clue why? Cheers!

@endel
Copy link
Contributor Author

endel commented Jun 14, 2018

FYI this problem doesn't happen in emscripten environment since the browser handles PING/PONG messages automatically

@britzl
Copy link
Owner

britzl commented Jun 15, 2018

In the official LuaWebsocket project there's an issue discussing PING/PONG: lipp/lua-websockets#94

@britzl britzl closed this as completed in 12b2816 Jun 16, 2018
britzl added a commit that referenced this issue Jun 16, 2018
implement PING/PONG protocol. fixes #2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants