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

WebSockets send can wait forever and async send seems to be broken #1063

Open
bryaan opened this issue Jun 13, 2023 · 3 comments
Open

WebSockets send can wait forever and async send seems to be broken #1063

bryaan opened this issue Jun 13, 2023 · 3 comments

Comments

@bryaan
Copy link

bryaan commented Jun 13, 2023

I find myself wanting to use @async send(ws, msg) because its possible for the send to wait forever. But it is causing the error below. Without fixing this all websocket servers using this lib are broken.

│ HTTP.WebSockets.WebSocketError(HTTP.WebSockets.CloseFrameBody(1007, "Invalid UTF-8"))

@bryaan bryaan changed the title WebSockets send needs a timeout WebSockets async send seems to be broken Jun 13, 2023
@bryaan bryaan changed the title WebSockets async send seems to be broken WebSockets send can wait forever and async send seems to be broken Jun 13, 2023
@bryaan
Copy link
Author

bryaan commented Jun 15, 2023

The fix for now seems to be adding a reentrantlock and doing something like this:

   try
        msg = deepcopy(msg) # So we dont modify concurrently 
        @async begin
            lock(ws.lock) do
                send(ws.client, JSON3.write(msg))
            end
        end
    catch

    end

It would be very nice if the lib did this internally. Any issues with that?

@chelyabinsk
Copy link

This would be great to get done

@BambooFlower
Copy link

I would also appreciate this addition to the lib

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

3 participants