Closed
Description
Hi,
The problem reported in issue #363 happens in my released app. Looks like there is a concurrency issue inside the library code.
WebSocket.processInputStream
is called from WebSocket.stream
delegate in a background thread. While the function is being executed, a client code may call WebSocket.disconnect
in main queue. So it could happen that between WebSocket.processInputStream
start and let length = inputStream!.read(buffer, maxLength: BUFFER_MAX)
line inputStream
becomes nil
and inputStream!
unwrapping crashes.
Client code has no access to WebSocket.stream
thread and hence has no way to avoid this issue from happening.
Does it make sense to dispatch WebSocket.stream
body execution to main queue?
Metadata
Metadata
Assignees
Labels
No labels
Activity