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

io https server crashes with SocketException after a while #31558

Open
welopino opened this Issue Dec 6, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@welopino

welopino commented Dec 6, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment