Skip to content

io https server crashes with SocketException after a while #31558

Open
@welopino

Description

This little https server script runs for a while.

import 'dart:io';
import 'package:http_server/http_server.dart';

main() async {
   
   
  //files
  var staticFiles = new VirtualDirectory(".....");
  staticFiles.allowDirectoryListing = true;
  staticFiles.directoryHandler = (dir, request) {
    var indexUri = new Uri.file(dir.path).resolve('index.html');
    staticFiles.serveFile(new File(indexUri.toFilePath()), request);
  };

  //https
  SecurityContext context = new SecurityContext();
  var chain =   Platform.script.resolve('certificate+intermediateCertificate.pem').toFilePath();
  var key =    Platform.script.resolve(''key.pem').toFilePath();
  context.useCertificateChain(chain);
  context.usePrivateKey(key, password: '...');
  HttpServer
    .bindSecure(InternetAddress.ANY_IP_V6, 443, context)
    .then((server) {
      server.forEach(staticFiles.serveRequest);
    }
  );
}

After a while it crashes, and I get this:

Unhandled exception:
SocketException: OS Error: Connection reset by peer, errno = 104, address = ::, port = 443
#0      _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1108)
#1      _microtaskLoop (dart:async/schedule_microtask.dart:41)
#2      _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#3      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:99)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:152)

On the same Ubuntu server a java based Vert.x sever runs a https service without problems.

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-io

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions