You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple request like getting the string "hello" using the http package from a shelf server running on the same host takes an unusually long time (5 seconds) when the url refers to localhost on my mac. The same connection takes less than 5 milliseconds on Chrome. The request takes less than 100 ms when the url uses 127.0.0.1 instead of localhost. I repeated the test on an Ubuntu Linux machine using localhost and it behaves as expected.
client
import 'package:http/http.dart' as http;
main(List<String> args) async {
var client = new http.Client();
Stopwatch sw = new Stopwatch();
sw.start();
var response = await client.get(Uri.parse("http://localhost:10080"));
sw.stop();
print('response received ${sw.elapsedMilliseconds}');
client.close();
}
server
import 'dart:io';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart';
main(List<String> args) async {
var handler = (Request r){
return new Response.ok("hello");
} ;
var server = await serve(const Pipeline()
.addMiddleware(logRequests())
.addHandler(handler), InternetAddress.ANY_IP_V4, 10080);
print('Serving at http://${server.address.host}:${server.port}');
sdk: 1.19.1
mac os x: 10.11.6
http: 0.11.3+9
shelf: 0.6.5+3
The text was updated successfully, but these errors were encountered:
ErikGrimes
changed the title
localhost connection performance issue on mac os x
performance issue on mac os x when using localhost in url
Oct 14, 2016
A simple request like getting the string "hello" using the http package from a shelf server running on the same host takes an unusually long time (5 seconds) when the url refers to localhost on my mac. The same connection takes less than 5 milliseconds on Chrome. The request takes less than 100 ms when the url uses 127.0.0.1 instead of localhost. I repeated the test on an Ubuntu Linux machine using localhost and it behaves as expected.
client
server
sdk: 1.19.1
mac os x: 10.11.6
http: 0.11.3+9
shelf: 0.6.5+3
The text was updated successfully, but these errors were encountered: