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

Connection refused when fetching status for root key of local replica #4

Closed
andreasckoch opened this issue Jun 20, 2021 · 4 comments
Closed
Labels
solved The issue has been confirm solved

Comments

@andreasckoch
Copy link

I'm encountering this error when calling fetchRootKey() of HttpAgent in _initAgent():

E/flutter (23155): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: http request failed because SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 46950
E/flutter (23155): #0 HttpAgent._defaultFetch (package:agent_dart/agent/agent/http/index.dart:433:7)
E/flutter (23155):
E/flutter (23155): #1 HttpAgent.status (package:agent_dart/agent/agent/http/index.dart:362:20)
E/flutter (23155):
E/flutter (23155): #2 HttpAgent.fetchRootKey (package:agent_dart/agent/agent/http/index.dart:246:20)
E/flutter (23155):
E/flutter (23155): #3 AgentFactory._initAgent (package:agent_dart_example/init.dart:63:7)
E/flutter (23155):
E/flutter (23155):

This means that the port somehow gets changed since I specified port 40161 in the url of the AgentFactory (this is where my local replica runs).
I also tried to directly set the port with the host parameter of HttpAgentOptions but still get the same error.

Am I missing something?

@neeboo
Copy link
Contributor

neeboo commented Jun 20, 2021

url: "http://192.168.3.11:57229",

Just do it here, like http://localhost:40161

or can you post your code here to see what's going on there

@andreasckoch
Copy link
Author

Yes, that's how I did it

I also tried to set the host directly when initializing HttpAgentOptions at

options: HttpAgentOptions()..identity = _identity);
:
like options: HttpAgentOptions()..identity=_identity..host='localhost:40161',
but still got the same error..

As far as my setup is concerned, your scripts to build the binaries and link them worked without errors and I'm using an Android Pixel 2 API 29 emulator. (also had to change to $ANDROID_NDK_HOME in variables.sh)

Btw, I found a typo here:

late String deaultPort;

This should probably be defaultPort

@neeboo
Copy link
Contributor

neeboo commented Jun 21, 2021

Yes, that's how I did it

I also tried to set the host directly when initializing HttpAgentOptions at

options: HttpAgentOptions()..identity = _identity);

:
like options: HttpAgentOptions()..identity=_identity..host='localhost:40161',
but still got the same error..
As far as my setup is concerned, your scripts to build the binaries and link them worked without errors and I'm using an Android Pixel 2 API 29 emulator. (also had to change to $ANDROID_NDK_HOME in variables.sh)

Btw, I found a typo here:

late String deaultPort;

This should probably be defaultPort

First, thanks for pointing out the typo. will be fixed in next release.

Second, if you use Android emulator , the emulator connects localhost will use "10.0.2.2" instead of "localhost" or "127.0.0.1".

In your case, you should try "http://10.0.2.2:40161" just in the url field

neeboo added a commit that referenced this issue Jun 21, 2021
@andreasckoch
Copy link
Author

Thanks that was it!
Closing this issue.

neeboo added a commit that referenced this issue Jun 22, 2021
neeboo added a commit that referenced this issue May 26, 2022
@AlexV525 AlexV525 added the solved The issue has been confirm solved label Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved The issue has been confirm solved
Projects
None yet
Development

No branches or pull requests

3 participants