drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.6k stars 1.12k forks source link

Websocket Connection Keep Live but Message Not received in drogon::WebSocketController<Ws>::handleNewMessage() #1647

Open kapilpipaliya opened 1 year ago

kapilpipaliya commented 1 year ago

When big message is send from web browser WebSocket client to Drogon WebSocket endpoint, message is not received in handleNewMessage() WebSocket handler function, and client can not send further WebSocket messages too. client_max_body_size and client_max_websocket_message_size has no effect on it. try to spend whole day to fix it but it seems a bug.

Desktop:

an-tao commented 1 year ago

Did you change the relevant option in the config file?

        //client_max_websocket_message_size: Set the maximum size of messages sent by WebSocket client. The default value is "128K".
        //One can set it to "1024", "1k", "10M", "1G", etc. Setting it to "" means no limit.
        "client_max_websocket_message_size": "128K",
kapilpipaliya commented 1 year ago

yes, I set it to 99G and "", but still websocket messages are not received when its big. for very small messages It's received fine. also once the WebSocket message is blocked no further communication can be done, but the connection still kept alive.

an-tao commented 1 year ago

What is the size of messages that can't be processed?would you please make a demo to reproduce this issue?

kapilpipaliya commented 1 year ago

I created a sample application here: https://github.com/kapilpipaliya/drogon_websever_websocket_sample

  1. run the server
  2. open this page: https://livepersoninc.github.io/ws-test-page/
  3. enter url: ws://localhost:8849/chat
  4. open this page: https://onlinefiletools.com/generate-random-text-file and generate 10m text file
  5. paste text in point 2 page.
  6. click Send 5 times.
  7. Then backend is not able to send the response.
an-tao commented 1 year ago

@kapilpipaliya Hi, what OS are you running the server on? I ran your demo server and it worked fine, on MacOS

kapilpipaliya commented 1 year ago

I am using Arch linux.

kapilpipaliya commented 1 year ago

@an-tao Can you please test on linux?

kapilpipaliya commented 1 year ago

I think its a bug with big data. When Uploading this payload, I cant get response. image I see this logs in the console:


20230729 14:07:47.512755 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:47.512818 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:47.512849 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:47.512866 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:47.512909 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:47.512951 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:47.513037 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:47.513069 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.007984 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.008138 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.008196 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.009905 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.009967 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.010008 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.011011 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.011050 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.011081 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.012228 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.012282 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.013186 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.013217 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
20230729 14:07:49.058523 UTC 6985 TRACE [parse] data encoded! - WebSocketConnectionImpl.cc:282
an-tao commented 1 year ago

@kapilpipaliya thanks for your feedback, would u please use gdb to debug this issue step by step? you could add some information such as buffer length to the log in the 282 line and please note the "isFin" flag.