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

'Normal closure' on stop() string confuses golang.org/x/net/websocket #451

Open
qknight opened this issue Mar 15, 2023 · 5 comments
Open

Comments

@qknight
Copy link

qknight commented Mar 15, 2023

Problem

The default implementation of stop() sends this data, which can be seen in wireshark:

0000 03 e8 4e 6f 72 6d 61 6c 20 63 6c 6f 73 75 72 65 ..Normal closure

This confused my go application because it received a message with the contents:

/R"<\n

And it was quite hard to debug. I'm not sure if this is a bug at all. It seems that golang.org/x/net/websocket interpretes the reason as a normal message but instead of the text

'Normal closure' 

I see

'/R"<\n' 

with \n being a newline.

Solution

m_webSocket->stop(ix::WebSocketCloseConstants::kNormalClosureCode, "");

Detailed problem & solution

default stop code confused my application

-- IXWebSocket.h --
// stop is synchronous
void stop(uint16_t code = WebSocketCloseConstants::kNormalClosureCode,
     const std::string& reason = WebSocketCloseConstants::kNormalClosureMessage);

Adaption to the stop call

FilesClient::~FilesClient()
{
    LOGL(<< "Disconnecting websocket", LogLevel_INFO);
    m_webSocket->stop(ix::WebSocketCloseConstants::kNormalClosureCode, "");
}
@bsergean
Copy link
Collaborator

ps: have you tried to use the gorilla library, or something more recent? I think that net module is not super supported and legacy.

@qknight
Copy link
Author

qknight commented Apr 7, 2023

In pankat I use these libraries:

"github.com/gocraft/web"
"golang.org/x/net/websocket"
"net/http"

Maybe I should have tried a more recent implementation. For me it works right now but on the next iteration I keep this in mind.

I've added this issue in case someone gets down the same rabbit hole.

@qknight
Copy link
Author

qknight commented Apr 7, 2023

https://github.com/gorilla development has stalled also.

@bsergean
Copy link
Collaborator

bsergean commented Apr 7, 2023 via email

@qknight
Copy link
Author

qknight commented Apr 10, 2023

https://github.com/gobwas/ws maybe I'll give this a try this week.

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