Skip to content
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

demo hang #269

Open
nlphacker opened this issue Apr 28, 2015 · 1 comment
Open

demo hang #269

nlphacker opened this issue Apr 28, 2015 · 1 comment

Comments

@nlphacker
Copy link

Try to call http in C#. but it hangs at the below line

      var result = await createHttpServer(9999);  

full code is below

 static async void TestHttp()
    {
        var createHttpServer = Edge.Func(@"
            var http = require('http');

            return function (port, cb) {

            var server = http.createServer(function (req, res) {
                    res.end('Hello, world! ' + new Date());
                }).listen(port, cb);

               // cb(null, 'Node.js welcomes'); 
            };
        ");

        var result = await createHttpServer(9999);
        Console.WriteLine("done");
        Console.WriteLine(await new WebClient().DownloadStringTaskAsync("http://localhost:9999"));
    }




    static void Main(string[] args)
    {
        // Task.Run((Action)Start).Wait(); 

        Task.Run((Action)TestHttp).Wait();
        new ManualResetEvent(false).WaitOne();
    }
@simoneb
Copy link

simoneb commented May 3, 2015

I noticed that as well, but realized that (for unknown reasons), if I put a console.log statement somewhere it does work:

return function(port, callback) {
    console.log('creating server'); // <--- here
    var server = http.createServer(function(req, res) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants