Although the Web implementation works, the android emulator as well as my device does not connect to WebSocket. The following event error code is received where the error is thrown and then disconnected:
connection error
Event {
"isTrusted": false,
"message": "Failed to connect to /127.0.0.1:8000",
}
connection closed
Event {
"isTrusted": false,
"message": "Failed to connect to /127.0.0.1:8000",
}
The default websocket port for android emulator is the following, which is different from web.
android: "http://10.0.2.2:8000",
web: "http://127.0.0.1:8000",
#sib mentions the right ip but not the correct reason.
The reason why you need 10.0.2.2 on Android is that that's how you access the localhost via the android emulator. See the Android Docs.
On the iOs Emulator, you (should not) get the error, because there you access localhost on 127.0.0.1 as most people would anticipate
Related
Using the AWS IoT Device SDK from GitHub, I'm testing from my local machine using the basic_discovery.py script I can see that it returns the IP address and port from my Raspberry PI running as a Greengrass device, however, I see that I'm getting invalid return codes from the subsequent request when it is attempting to connect with the PI device. The error messages I am getting are as follows:
Trying core arn:aws:iot:us-east-1:111111111111:thing/GreengrassPI at host 192.168.1.176 port 8883
[ERROR] [2022-07-20T20:42:02Z] [00007000017de000] [mqtt-client] - id=0x7fd8b24b4b60: invalid connect return code 4, disconnecting
[ERROR] [2022-07-20T20:42:02Z] [00007000017de000] [tls-handler] - id=0x7fd89242aba0: error reported during SSLRead. OSStatus code -9805
Connection failed with exception AWS_ERROR_MQTT_PROTOCOL_ERROR: Protocol error occurred.
All connection attempts failed
[ERROR] [2022-07-20T20:42:02Z] [0000000116728e00] [mqtt-client] - id=0x7fd8b24b4b60: Connection is not open, and may not be closed
Any suggestions as to what to check? I did not see anything on this in the troubleshooting guide.
[SOLVED] So what I found was that the device name I was using in the test script was not listed in the client device associations for the Greengrass core device. Adding the association resolved the problem. For anyone else that runs into something similar refer to this for information on associating devices. In summary what happened is that the script was able to look up the Greengrass core device but when it attempted to send an MQTT message to it, the Greengrass core device refused it because the device was not associated to it.
I try to use the slack-sample bot from this blogpost https://www.opsdash.com/blog/slack-bot-in-golang.html . I've successfully created my api token, but i can not connect to the websocket server (the rtm.start request passs normally). I've get the error message
dial tcp 54.242.95.213:443: connectex: No connection could be made because the target machine actively refused it
I've also tried to connect via a chrome app called Simple Web Socket Client and via a website based one tester. Both work well, i can establish a connection and i can send data.
I'm behind a proxy, but i only have troubles with golang's websocket.Dial function.
Does anybody know why this can happen?
I use:
- Windows 7 SP1 x64
- Golang 1.7.1 windows/amd64
Greetings
Tonka
If you are using gorilla/websocket, it has the ability to use a Proxy. From issue 107:
import "net/http"
...
var dialer = websocket.Dialer{
Proxy: http.ProxyFromEnvironment,
}
If you are using golang.org/x/net you should switch to gorilla/websocket.
last week I started to develop apps for a Samsung Smartwatch with the Tizen SDK 2.4.0. My sample web application connects to a remote Websocket server (a simple echo server) and sends some random requests and prints the received messages (Server is http://www.websocket.org/echo.html). This works fine on an emulated devices as well as on the real Gear S2 Smartwatch (Example was taken from https://developer.tizen.org/zh-hans/development/tutorials/web-application/w3chtml5supplementary-features/communication/websocket?langredirect=1)
But as soon as I start a Websocket server in my home LAN I run into problems. The server is launched via a simple Python example I found on Github (https://github.com/dpallot/simple-websocket-server). The emulator device from the SDK connects to this server without any problems using the local IPv4. But the real device, which is logged in to the same WiFi access point, doesn't.
Note that the connection between my PC and my watch device works fine, since the SDK flashes the developed apps via WiFi to the device.
In my config.xml all connections are allowed
<access origin="*" subdomains="true"></access>
and the privilege for "Internet" is available.
The logs show that the watch tries to open a connection, but is then stuck. No error message is printed - the watch just does not go beyond the initial creation of the websocket.
Do you have any hints or thoughts about how I could debug this issue?
Thanks in advance!
I found the solution - my virus scanner has an integrated software firewall that blocked incoming connections...
Try with higher ports maybe ? I got WS working fine on SamsungZ1 on Tizen:2.3:Mobile
https://twitter.com/RzrFreeFr/status/70135763074535014#tizen-gear2-websockets
Maybe I could try your code on Tizen:2.4:Mobile too ?
I have an unpublished custom receiver app, and I am unable to cast to it from my web player sender app in chrome. I do get the receiver "available" message upon initialization of cast api, but when I click on the cast button in player and select the chromecast device from drop down menu in extension, the TV screen goes black and few seconds later I get onError method called with following error:
{code: "channel_error", description: "Error: Timeout", details: null}
The casting works fine when using default media receiver. Also, I do not see any network traffic coming from chromecast device in my server console log, which means that chromecast is not fetching the receiver application.
I made sure of the following:
The Chromecast dongle is registered as Cast Receiver device in Cast
Developer console.
My macbook has NodeJS server running to serve the
receiver application and the "Receiver Application URL" in cast
developer console is correctly pointing to server running on my
macbook.
The chromecast and my macbook both are on same network, with
valid 192.168.x.x IP addresses.
I found another thread discussing this error Chromecast sample sender application CastHelloText-chrome ends with error when trying to get session, but the suggestions provided there dont seem to apply to my situation.
I was able to resolve this particular error by restarting the chromecast device. I tried it on two separate occasions and both times the issue went away once the device was restarted. I can't explain how it worked, but it did the job. If someone can explain what is the cause of this particular error and why restarting fixes it, I will accept that answer.
Whenever I activate debugging over Bluetooth on my wearable emulator, the device starts vomiting this error every 10 milliseconds on the console:
08-07 12:15:53.472 1484-29405/com.google.android.apps.wearable.settings W/AdbTargetService﹕ error during createTcpConnection
java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 7272): connect failed: ECONNREFUSED (Connection refused)
at libcore.io.IoBridge.connect(IoBridge.java:124)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:163)
at java.net.Socket.startupSocket(Socket.java:590)
at java.net.Socket.tryAllAddresses(Socket.java:128)
at java.net.Socket.<init>(Socket.java:178)
at java.net.Socket.<init>(Socket.java:150)
at com.google.android.clockwork.settings.AdbTargetService$PipeControlThread.createTcpConnection(AdbTargetService.java:203)
at com.google.android.clockwork.settings.AdbTargetService$PipeControlThread.access$400(AdbTargetService.java:81)
at com.google.android.clockwork.settings.AdbTargetService$PipeControlThread$2.run(AdbTargetService.java:153)
at java.lang.Thread.run(Thread.java:818)
Caused by: android.system.ErrnoException: connect failed: ECONNREFUSED (Connection refused)
at libcore.io.Posix.connect(Native Method)
at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:111)
at libcore.io.IoBridge.connectErrno(IoBridge.java:137)
at libcore.io.IoBridge.connect(IoBridge.java:122)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:163)
at java.net.Socket.startupSocket(Socket.java:590)
at java.net.Socket.tryAllAddresses(Socket.java:128)
at java.net.Socket.<init>(Socket.java:178)
at java.net.Socket.<init>(Socket.java:150)
at com.google.android.clockwork.settings.AdbTargetService$PipeControlThread.createTcpConnection(AdbTargetService.java:203)
at com.google.android.clockwork.settings.AdbTargetService$PipeControlThread.access$400(AdbTargetService.java:81)
at com.google.android.clockwork.settings.AdbTargetService$PipeControlThread$2.run(AdbTargetService.java:153)
at java.lang.Thread.run(Thread.java:818)
08-07 12:15:53.476 1229-1229/system_process D/ZenLog﹕ disable_effects: 0|com.google.android.apps.wearable.settings|11003|null|1000,listenerHints
In my code I send a message from wearable to handheld. The message is correctly sent, but the debugger doesn't stop at any breakpoints within the WearableListenerService class on the handheld module and seems that that code is not getting executed.
Complementary info:
Device: Genymotion Samsung Galaxy S4, API 19, 4.4.4.
Wearable device: ADV Emulator Square, API 21
Same applicationId
Same versionNumber
Wearable project added as a dependency in handheld project as wearApp project(':wear')
No <uses-permission> tags
Android Wear installed via apk dropping on emulator: com.google.android.wearable.app-1.1.1.2016316-702016316-minAPI18
Debug over bluetooth activated on handheld device and devices paired
Host: connectedTarget: disconnected. It doesn't connect when I execute adb -s 192.168.56.102:5555 forward tcp:4444 localabstract:/adb-hub
adb connect localhost:4444, however, a third useless device seems to be created in a perpetual offline status and it can't be used to run anything on it:
Nor Revoking permissions or factory reset (as suggested in the post Android Wear device selection box says "offline localhost:4444 minSdk (API 20) > deviceSdk (API 1)"
) are working.
It happens that I was misunderstanding everything. If you're using an emulated wearable, there is NO need to:
Activate "Debugging over Bluetooth" in the wearable.
Redirect ports with adb -s 192.168.56.102:5555 forward tcp:4444 localabstract:/adb-hub and
adb connect localhost:4444.
And even both target and host devices can appear as "disconnected".
All you need is to execute adb -s handheldDeviceName forward tcp:5601 tcp:5601 so the handheld is paired with the emulator and then you can start debugging without further concerns.
Trouble was that in Android Studio you can debug just one module at a time with the icon for debugging: .
If you want to debug both modules at the same time so you can trace all the breakpoints, you have to use the debugging button with one module and then attach a debugger to the other device .
Both devices will be available in the list displaying their proccesses once they are paired.
I had this problem with the moto 360 and solved with this tutorial:
http://melix.github.io/blog/2014/10/android-moto360.html
So you were looking at a solution, and here it is. Basically, the problem is that the Android companion app doesn’t store its settings under its cache. They are stored in the Google Play Services space, so here is the procedure that worked for me, and I sincerely hope it will do for you. On your handheld:
open the applications settings, search for the Android Wear application, then force stop it
clear its data and cache
now search for Google Play Services (depending on your language settings, it can appear with a different name, on m y device it is "Services Google Play".
click on Manage space. You will see that there’s a section for connected devices. I tried to clear data here, but it didn’t help, so you have to click on delete all data.
reboot your phone
reboot your Moto 360
I am unsure that the two last steps are really necessary, but I did it because I wanted to make sure that force stopping and clearing data did not introduce some weird behavior after that. When you reopen the Android Wear companion app, it should now be as if it was the first time you opened it and ask you to associate it with your watch. Do it, and now, you should be able to follow the normal procedure described in the Android documentation and…
If you're on a Mac try this before you go resetting everything unnecessarily (note the 127.0.0.1 instead of localhost):
adb forward tcp:4444 localabstract:/adb-hub
adb connect 127.0.0.1:4444
When localhost resolves to both ::1 (IPv6) and 127.0.0.1 (IPv4), connecting to 127.0.0.1 may help on Linux as well, not just Mac:
$ adb forward tcp:4444 localabstract:/adb-hub
$ adb connect localhost:4444
unable to connect to localhost:4444: Connection refused
$ adb connect 127.0.0.1:4444
connected to 127.0.0.1:4444
$ adb devices
List of devices attached
127.0.0.1:4444 device
...
$