4

I've built a web server using Chrome Packaged Apps. The problem I see repeatedly is that chrome.socket.accept() and chrome.socket.write() don't invoke their callback functions. It usually works more or less reliably if request rate is less than 1 request per seconds. If I go above that, then I start seeing errors or missing callbacks.

I did similar tests with sample "webserver" app build by Google (https://github.com/GoogleChrome/chrome-app-samples/tree/master/webserver). It has the same problem. It usually takes less than 100 requests before web server stops responding. The easiest way to reproduce the problem is to use Chrome browser as a client and hold F5 key for few seconds.

It would be desirable to have a sample app that demonstrates how to build reliable web server using chrome.socket. So far I tried several different workarounds for monitoring the situation from the app itself and restarting socket when socket stops working, but it's not easy because there is no reliable way to check the status of the connection or status of the last operation when callback is not fired. I tried to use getInfo() method, but it always returns "connected=true" regardless of the situation.

I saw this on Windows 7 and Chrome OS (Chromebook).

Josh Lee
  • 149,877
  • 34
  • 253
  • 263
Oleg K
  • 444
  • 4
  • 7
  • To clarify: do you see the same rate/speed of failure in your own server as in the server code sample on Github? If it is the same, it seems likely that is a bug in how Chrome handles server sockets. If they are different, it still seems like a bug, but there may be something aggravating the problem in the worse case. – apsillers Aug 06 '13 at 20:35
  • I see the same rate/speed of failure in my app and sample app. It does look like bug in how Chrome handles server sockets. Thanks. – Oleg K Aug 07 '13 at 15:17
  • Yeah, I'd definitely suggest filing a bug at http://crbug.com (especially since Google's sample app already supplies the test code). Best case, your bug is valid and they fix the underlying socket code. Worst case, there is no bug in the API, but Google fixes the sample server code to work properly. – apsillers Aug 07 '13 at 15:23
  • 1
    Your issue (or at least a very closely related issue) [has been reported as a bug in Chromium](https://code.google.com/p/chromium/issues/detail?id=170595); you can star it to express interest in the bug and get updates. – apsillers Aug 07 '13 at 19:51
  • Thanks for the tip @apsillers. I starred that issue and added my comment as well. Hope this bug will get some attention. – Oleg K Aug 07 '13 at 21:12

2 Answers2

1

Just an update on this. According to this the issue is now fixed.

Oleg K
  • 444
  • 4
  • 7
1

There are still other problems with the sample web server application. I noticed that I could make the sample app lock up by holding down Ctrl-R in the browser. I wrote a more robust one that you can use here: https://github.com/kzahel/web-server-chrome

kzahel
  • 2,587
  • 1
  • 18
  • 26