stomp icon indicating copy to clipboard operation
stomp copied to clipboard

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

Open eshiett1995 opened this issue 6 years ago • 8 comments

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 avatar Nov 05 '18 13:11 eshiett1995

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

});

eshiett1995 avatar Nov 05 '18 18:11 eshiett1995

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)

zahariaca avatar Nov 27 '18 17:11 zahariaca

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

Mikaulin avatar Nov 29 '18 14:11 Mikaulin

@Mikaulin no i havent

eshiett1995 avatar Dec 16 '18 12:12 eshiett1995

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.

xbassols avatar Dec 18 '18 17:12 xbassols

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

Philip-Wu avatar Jan 17 '19 23:01 Philip-Wu

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!

saurabhgour avatar Mar 30 '19 19:03 saurabhgour

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

UnDer-7 avatar Oct 18 '19 02:10 UnDer-7