1
をスローします。例外は:ダートのhttpサーバは、この単純なダーツプログラムが起動し、しばらくの間実行されますが、いくつかの相互作用の後に例外をスローする例外
Unhandled exception:
SocketException: OS Error: Broken pipe, errno = 32, 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)
バグですか?
どうすれば問題を解決できますか?
...別のトピック...なぜ、適切なパスワードを入力せずにhttpsサーバを起動できますか?私は、サーバーがパスワードが正しいかどうかをチェックすると期待していますか?
私は例外
import 'dart:io';
import 'package:http_server/http_server.dart';
main() async {
//files
var staticFiles = new VirtualDirectory("file");
staticFiles.allowDirectoryListing = true;
staticFiles.directoryHandler = (dir, request) {
try{
var indexUri = new Uri.file(dir.path).resolve('index.html');
staticFiles.serveFile(new File(indexUri.toFilePath()), request);
} catch(a,b) {
print(a);
print(b);
}
};
//http
HttpServer
.bind(InternetAddress.ANY_IP_V6, 80)
.then((server) {
try{
server.forEach(staticFiles.serveRequest);
} catch(a,b)
{
print(a);
print(b);
}
}
);
//https
SecurityContext context = new SecurityContext();
var chain = Platform.script.resolve('file.pem').toFilePath();
var key = Platform.script.resolve('file.pem').toFilePath();
context.useCertificateChain(chain);
context.usePrivateKey(key, password: 'pwd');
HttpServer
.bindSecure(InternetAddress.ANY_IP_V6, 443, context)
.then((server) {
try {
server.forEach(staticFiles.serveRequest);
} catch(a, b){
print(a);
print(b);
}
}
);
をキャッチそれを解決しようとしたが、それは...
私のプログラムで発生した例外の原因は何ですか? – Michael