WebSocket, Invalid request method, uri = http://127.0.0.1:8989/

41 views
Skip to first unread message

Jon Kleiser

unread,
Nov 1, 2017, 4:56:16 AM11/1/17
to Dart Misc
Hi,

I have written (stolen) a simple stand-alone WebSocket client that works fine when connecting to e.g. ws://demos.kaazing.com/echo, but when I try to connect to a local WebSocket server written i Pony, I get this:

Unhandled exception:
HttpException: Invalid request method, uri = http://127.0.0.1:8989/
#0      _HttpParser._doParse (dart:io/http_parser.dart:428)
#1      _HttpParser._parse (dart:io/http_parser.dart:318)
#2      _HttpParser._onData (dart:io/http_parser.dart:804)

My Dart progam looks like this:

import "dart:io";

void receivedData(data) {
  print("Received: $data");
}

main() async {
  var socket = await WebSocket.connect("ws://127.0.0.1:8989/");

  socket.listen((data) {
    receivedData(data);
  });
  
  for (int i=1; i<4; i++) {
    socket.add("dart-$i");
  }
}

Can you spot any problems with this code?

I have reported the problem to the developer of the Pony WebSocket library, here:

/Jon

Jon Kleiser

unread,
Nov 1, 2017, 9:40:41 AM11/1/17
to Dart Misc
The "Invalid request method" problem was solved by converting all headers to lower case in the Pony WebSocket library.

Florian Loitsch

unread,
Nov 1, 2017, 10:53:34 AM11/1/17
to mi...@dartlang.org
Thanks for following up with the Pony developers.
Looks like Dart and Pony now work well together.

--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
Reply all
Reply to author
Forward
0 new messages