-
Notifications
You must be signed in to change notification settings - Fork 50
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
MbedTLS > 0.6.3 problem with WebSockets #186
Comments
The first thing I notice is I think it would make more sense to say I note that inside
julia> @which read(MbedTLS.SSLContext(), 7)
read(s::IO, nb::Integer) in Base at io.jl:827 This in turn calls This function follows the spec for
|
Have you tried the Your example seems to run ok using julia> function mwe()
HTTP.WebSockets.open("wss://echo.websocket.org") do io
@sync begin
@async while isopen(io)
x = String(readavailable(io))
println(now(), " READ: ", x)
end
for i in 1:5
write(io, string(i))
println(now(), " WROTE: ", i)
sleep(rand(1:5))
end
close(io)
end
println("done")
end
nothing
end
mwe (generic function with 1 method)
julia> mwe()
2018-11-03T10:19:09.533 WROTE: 1
2018-11-03T10:19:10.049 READ: 1
2018-11-03T10:19:14.534 WROTE: 2
2018-11-03T10:19:15.062 READ: 2
2018-11-03T10:19:19.541 WROTE: 3
2018-11-03T10:19:20.063 READ: 3
2018-11-03T10:19:23.543 WROTE: 4
2018-11-03T10:19:24.069 READ: 4
2018-11-03T10:19:24.547 WROTE: 5
2018-11-03T10:19:25.066 READ: 5
2018-11-03T10:19:27.792 READ:
done |
Wow, thank you for this great response! HTTP.WebSockets does solve the issues here (I didn't really know it existed, since it isn't documented on the gh pages site). One only slightly related question before I go open a new issue: Can I close the websocket with a status code? You can do so with WebSockets.jl here. Having that would make HTTP's WebSockets a perfect replacement. |
The relevant method in It currently just sends a zero-length close packet: opcode = WS_FINAL | WS_CLOSE
write(ws.io, [opcode, 0x00]) You could modify this method to add a Note that the opcode = WS_FINAL | WS_CLOSE
if statuscode == nothing
write(ws.io, [opcode, 0x00])
else
wswrite(ws, opcode, reinterpret(UInt8, [hton(UInt16(statuscode)])
end PR welcome :) |
Thanks! I'll open an issue for that and give it a try when I have a chance. |
There seems to be a sort of lag/offset of one message when reading from a WebSocket on new versions of MbedTLS.jl.
Expected behaviour, WebSockets v1.0.3, MbedTLS 0.6.3:
WebSockets v1.0.3, MbedTLS master:
Interestingly (to me at least), the fifth read does return after the non-async loop exits.
I wish I could offer some suggestions as to what could be the problem but I'm completely in the dark.
The text was updated successfully, but these errors were encountered: