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

SocketException: Connection reset by peer (OS Error: Connection reset by peer) #55776

Open
leeflix opened this issue May 19, 2024 · 3 comments
Open
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io

Comments

@leeflix
Copy link

leeflix commented May 19, 2024

I am using websockets in my dart application. My server occasionally crashes when a "peer resets the connection". I think its odd that an exception crashes the program. Is there any way to handle this?

@lrhn lrhn added the area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. label May 19, 2024
@mraleph
Copy link
Member

mraleph commented May 22, 2024

You would need to post a reproduction etc. Without code we could debug this is unactionable.

@mraleph mraleph closed this as completed May 22, 2024
@mraleph mraleph reopened this May 22, 2024
@mraleph mraleph added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io needs-info We need additional information from the issue author (auto-closed after 14 days if no response) and removed area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. labels May 22, 2024
@leeflix
Copy link
Author

leeflix commented May 22, 2024

@mraleph I am not doing anything fancy basically everything i do boils down to this:

    // start listening for ws connections there is no problem here
    
    SecurityContext? securityContext;
    var server;
    if (Env.certificateChainPath != null && Env.privateKeyPath != null) {
      securityContext = SecurityContext()
        ..usePrivateKeyBytes(File(Env.privateKeyPath!).readAsBytesSync())
        ..useCertificateChainBytes(File(Env.certificateChainPath!).readAsBytesSync());
      server = await HttpServer.bindSecure(Env.local ? "localhost" : InternetAddress.anyIPv6, Env.wsPort, securityContext);
    } else {
      server = await HttpServer.bind(Env.local ? "localhost" : InternetAddress.anyIPv6, Env.wsPort);
    }

    // the problem should be after here

    await for (var request in server) {
        if (WebSocketTransformer.isUpgradeRequest(request)) {
          WebSocket ws = await WebSocketTransformer.upgrade(request);
          ws.add(...); // send data
        }
    }

@leeflix
Copy link
Author

leeflix commented May 22, 2024

I don't know where the error exactly occurs:

WhatsApp Image 2024-05-22 at 17 03 32

@github-actions github-actions bot removed the needs-info We need additional information from the issue author (auto-closed after 14 days if no response) label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io
Projects
None yet
Development

No branches or pull requests

3 participants