Closed RedRoserade closed 10 years ago
If you run this program, you'll get the same kind of results, so it's not a problem with sqljocky:
import 'dart:io';
main() {
var x = 0;
HttpServer.bind('localhost', 8089, backlog: 10).then((server) {
server.listen((request) {
x++;
print("Handling request $x");
// request.response.close();
});
});
print('Server running');
}
The problem is that the web browser doesn't try to make a second request for a resource if there's already a request for it in progress. If you open up multiple browsers you'll find that the dart program is still responding to requests.
(I didn't know that until today!)
Correct, it does happen to me as well with the code you posted, unless if the request comes from different browsers.
However, the code I sent does block even if the request comes from different browsers. In this picture, the requests came both from IE and Chrome. Chrome went first, and IE second, separated by about 2 to 3 seconds. IE's connection is taken only after the connection to the DB fails, which takes about 20 seconds.
That's strange. For me then it makes no difference whether I use your test code or mine - they both behave in the same way.
I can't think of any reason why making a connection to the mysql server would cause the http server to stop responding. Unless there's some bug in the Windows version of Dart which causes the VM to hang while connecting? I only have access to Linux machines at the moment.
A quick test on my Ubuntu Server VM confirms what you said. It's most likely a Dart VM bug on the windows version.
I guess it's time to make a bug report, I don't know what's causing it though (probably something related to Sockets?). I at least know that's still present on Dart 1.3.0 on Windows.
I reported this bug on the tracker, if you're interested. It does seem to be related to sockets. https://code.google.com/p/dart/issues/detail?id=18154&thanks=18154&ts=1397168596
I was trying out sqljocky for a small project, to try and see if it was worth using Dart instead of NodeJS.
The setup was as follows: -A Dart HttpServer was running on localhost, and requests queried a MySQL database. It was running on Windows. -The database was present on an Ubuntu Server virtual machine. -sqljocky was configured to target MySQL running on such vm.
Everything was fine, until the day which I turned off the VM and made a request to the server, to see what happened if the db couldn't be reached.
What happened was that the first request came and sqljocky started querying the db, but until that connection attempt times out, no more requests were treated by the HttpServer, even if they weren't dependent on the db.
In NodeJS's MySQL connector, even if the db can't be reached, subsequent requests are treated asynchronously.
Here's an excerpt of my code (could be me screwing up!), starting with the code that queries the db:
And finally, the code for the HttpServer: