rikulo / stomp

STOMP Dart Client for communicating with STOMP-compliant messaging servers.
http://rikulo.org
Other
30 stars 24 forks source link

Keep getting SocketException: Failed host lookup: 'ws://10.0.3.2:8080/websocket-example' (OS Error: No address associated with hostname, errno = 7) while trying to connect from an emulator #19

Open eshiett1995 opened 5 years ago

eshiett1995 commented 5 years ago

i am trying to connect to a socket via gennymotion emulator on my local box, using the gennymotion localbox ip of 10.0.3.32, here is my code bellow:

connect("ws://10.0.3.2:8080/websocket-example").then((StompClient client) {

//client.sendString("/foo", "Hi, Stomp");

});

but i keep getting the exception:

E/flutter ( 6573): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception: E/flutter ( 6573): SocketException: Failed host lookup: 'ws://localhost:8080/websocket-example' (OS Error: No address associated with hostname, errno = 7) E/flutter ( 6573): #0 _NativeSocket.lookup. (dart:io/runtime/binsocket_patch.dart:362:9) E/flutter ( 6573): #1 _RootZone.runUnary (dart:async/zone.dart:1379:54) E/flutter ( 6573): #2 _FutureListener.handleValue (dart:async/future_impl.dart:129:18) E/flutter ( 6573): #3 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45) E/flutter ( 6573): #4 Future._propagateToListeners (dart:async/future_impl.dart:671:32) E/flutter ( 6573): #5 Future._completeWithValue (dart:async/future_impl.dart:486:5) E/flutter ( 6573): #6 Future._asyncComplete. (dart:async/future_impl.dart:516:7) E/flutter ( 6573): #7 _microtaskLoop (dart:async/schedule_microtask.dart:41:21) E/flutter ( 6573): #8 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

why is this, and is this specific to emulator or am i calling the wrong tcp port

eshiett1995 commented 5 years ago

even using an online websocket url doesnt work connect("ws://echo.websocket.org").then((StompClient client) {

});

zahariaca commented 5 years ago

Having the same issue. Are we doing something wrong?

D/ViewRootImpl@e6d47e4[MainActivity](13974): ViewPostIme pointer 1
E/flutter (13974): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (13974): SocketException: Failed host lookup: 'ws://10.220.0.10:8080/gs-guide-websocket/websocket' (OS Error: No address associated with hostname, errno = 7)
E/flutter (13974): #0      _NativeSocket.lookup.<anonymous closure> (dart:io-patch/socket_patch.dart:353)
E/flutter (13974): #1      _RootZone.runUnary (dart:async/zone.dart:1381)
E/flutter (13974): #2      _FutureListener.handleValue (dart:async/future_impl.dart:129)
E/flutter (13974): #3      _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633)
E/flutter (13974): #4      _Future._propagateToListeners (dart:async/future_impl.dart:662)
E/flutter (13974): #5      _Future._completeWithValue (dart:async/future_impl.dart:477)
E/flutter (13974): #6      _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:507)
E/flutter (13974): #7      _microtaskLoop (dart:async/schedule_microtask.dart:41)
E/flutter (13974): #8      _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
Mikaulin commented 5 years ago

I am having the same problem when I try to connect to my local IP. Has anyone been able to solve it?

eshiett1995 commented 5 years ago

@Mikaulin no i havent

xbassols commented 5 years ago

For some reason the VM implementation is with Socket and that requires only an IP address and port and that setup does not work well with sprint.

In order to solve this problem I've used https://pub.dartlang.org/packages/web_socket_channel as socket library.

Here the example: custom_stomp.dart

For the authentication I'm fighting this problem https://github.com/dart-lang/web_socket_channel/issues/41 and I'm not sure if it's in this library or the socket library.

Philip-Wu commented 5 years ago

i'm having the same problem. anybody worked out where it's going wrong?

saurabhgour commented 5 years ago

Hey @xbassols, thanks for the workaround, it works great, since development for this plugin seems to be stopped, could you please fork the repo and include your changes there, it would really be helpful for everyone. Thanks again!

UnDer-7 commented 4 years ago

For some reason the VM implementation is with Socket and that requires only an IP address and port and that setup does not work well with sprint.

In order to solve this problem I've used https://pub.dartlang.org/packages/web_socket_channel as socket library.

Here the example: custom_stomp.dart

For the authentication I'm fighting this problem dart-lang/web_socket_channel#41 and I'm not sure if it's in this library or the socket library.

DUDE, THANK YOU, IT FINALLY WORKS. I SPENT TWO DAYS TRYING TO USE THIS LIBRARY