Connection always refused
I'm having a problem connecting two devices. I set up one as the host, the other as the guest. The host calls network.startNetworkService(...), no problem. The guest calls network.discoverNetworkServices(...), then in the callback i make a button to connect:
WifiActivityStatus.network.discoverNetworkServices(new SalutDeviceCallback() {
@Override
public void call(SalutDevice device) {
Log.d("WifiP2p", "A device has connected with the name " + device.deviceName);
WifiActivityStatus.opponentDevice = device;
WifiActivityStatus.activity.popButton(R.id.connect_button);
}
}, false);
This also works: when a host is found, the button appears.
This is the button's onClick method:
@Override
public void onClick(View v) {
onConnectButtonClicked();
}
}
And this is the onConnectButtonClicked() function:
...
WifiActivityStatus.network.registerWithHost(WifiActivityStatus.opponentDevice, new SalutCallback() {
@Override
public void call() {
Log.d("WifiP2p", "We're now registered.");
...something else...
}
}, new SalutCallback() {
@Override
public void call() {
Log.d("WifiP2p", "We failed to register.");
}
});
...
Now when i click the Connect button, i always get the following stacktrace:
07-11 16:41:02.264 20687-20687/com.tyde.friz.oeo D/Salut: Attempting to connect to another device.
07-11 16:41:10.727 20687-21254/com.tyde.friz.oeo D/Salut: Attempting to transfer registration data with the server...
07-11 16:41:10.731 20687-21254/com.tyde.friz.oeo W/System.err: java.net.ConnectException: failed to connect to /192.168.49.1 (port 37500): connect failed: ECONNREFUSED (Connection refused)
07-11 16:41:10.731 20687-21254/com.tyde.friz.oeo W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:124)
07-11 16:41:10.731 20687-21254/com.tyde.friz.oeo W/System.err: at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
07-11 16:41:10.731 20687-21254/com.tyde.friz.oeo W/System.err: at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:456)
07-11 16:41:10.731 20687-21254/com.tyde.friz.oeo W/System.err: at java.net.Socket.connect(Socket.java:882)
07-11 16:41:10.731 20687-21254/com.tyde.friz.oeo W/System.err: at java.net.Socket.connect(Socket.java:825)
07-11 16:41:10.731 20687-21254/com.tyde.friz.oeo W/System.err: at com.peak.salut.BackgroundClientRegistrationJob.doOnBackground(BackgroundClientRegistrationJob.java:41)
07-11 16:41:10.731 20687-21254/com.tyde.friz.oeo W/System.err: at com.arasthel.asyncjob.AsyncJob$2.run(AsyncJob.java:59)
07-11 16:41:10.731 20687-21254/com.tyde.friz.oeo W/System.err: at java.lang.Thread.run(Thread.java:818)
07-11 16:41:10.731 20687-21254/com.tyde.friz.oeo W/System.err: Caused by: android.system.ErrnoException: connect failed: ECONNREFUSED (Connection refused)
07-11 16:41:10.731 20687-21254/com.tyde.friz.oeo W/System.err: at libcore.io.Posix.connect(Native Method)
07-11 16:41:10.731 20687-21254/com.tyde.friz.oeo W/System.err: at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:111)
07-11 16:41:10.732 20687-21254/com.tyde.friz.oeo W/System.err: at libcore.io.IoBridge.connectErrno(IoBridge.java:137)
07-11 16:41:10.732 20687-21254/com.tyde.friz.oeo W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:122)
07-11 16:41:10.732 20687-21254/com.tyde.friz.oeo W/System.err: ... 7 more
07-11 16:41:10.732 20687-21254/com.tyde.friz.oeo E/Salut: An error occurred while attempting to register or unregister.
followed by the "We failed to register." log.
Can you please help me understand what am i doing wrong?
@tydeFriz I have the same issue, could you have find some answer in this 23 days?
I have the same problem and exception.
I have used this below code to create host
network.startNetworkService(new SalutDeviceCallback() {
@Override
public void call(SalutDevice salutDevice) {
deviceToSendTo = salutDevice;
Log.d(TAG, "Device: " + salutDevice.instanceName + " connected.");
}
});
When I press accept button nothing happened success or failure method hadn't been called..... But other device throws this above exception. connection refused .....
In the hosting site there is no callback called.........
@tydeFriz same problem for me :(