sta / sta/websocket-sharp

Unhandled Exception Crash in onAccept in EndPointListener

Open
#261 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

There is an unhandled exception problem in EndPointListener in onAccept on the line:
sock = lsnr._socket.EndAccept (asyncResult);
The type of exception is System.Net.Sockets.SocketException the NativeErrorCode is 10054 and the Message is An existing connection was forcibly closed by the remote host

This seems to happen if the connection is closed before it really started. See also:
http://stackoverflow.com/questions/7704417/socket-endaccept-error-10054

The current code only handles the ObjectDisposedException but should also handle at least the SocketException and make sure that listening for other incoming connections continues. See https://msdn.microsoft.com/en-us/library/chfa7866(v=vs.110).aspx for list of exceptions that should probably be handled.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at EndPointListener.onAccept, specifically the EndAccept call shown in the report, and review how ObjectDisposedException is currently handled. Verify that a SocketException with native error 10054 does not terminate acceptance of subsequent connections; done means the listener continues handling new incoming connections after the closed connection.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.