Android - TCP server Still connected but connection not working - android

Hey I'm developing a Kiosk application with a Mediatek Android Device. I have a single app running.
The app is running a TCP server waiting for messages. It works perfectly but after a few hours/days, the Internet connection is not working anymore:
The device still has its IP
Android thinks the device is still connected
Cannot ping from the Device or To the Device
Only solution is to disable WiFi and the start it again.
Do you have an idea why this kind of issue is happening? How can I avoid it? Any idea how I can debug this issue?

Related

Connection refused: ADB connection from Iphone to windows

I am trying to build a watch face for Android wear. The Android wear is an emulator and the device that I have is an iPhone connected via USB to my windows laptop
I have followed the instructions from the below link
https://developer.android.com/studio/command-line/adb.html ,
verified device compatibility as per
https://www.android.com/wear/check/
and have also followed responses as per the answers # adb connection over tcp not working now, however I am receiving the following error
unable to connect to :5555: cannot connect :5555: No conn
ection could be made because the target machine actively refused it. (10061)
Actively refused it means that the host sent a reset instead of an ack when you tried to connect. It is therefore not a problem in your code. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port. You may also want to check these SO posts: Trouble debugging android wear over bluetooth - Unable to connect to localhost and No connection could be made because the target machine actively refused it? which also stated that the machine exists but that it has no services listening on the specified port, or there is a firewall stopping you. You may check it out.
Thanks. I was able to figure out with some research that getting to have iPhone with a wearable emulator may not be possible and decided to have both my device and wearable as emulators. Though it was difficult, I was able to get both my emulators talk to each other with the below link Pairing Android and Wear emulators and https://kennethmascarenhas.wordpress.com/2014/08/19/developing-for-android-wear-with-emulators/?utm_source=Android%20Weekly&utm_campaign=a97f04efe2-Android_Weekly_116&utm_medium=email&utm_term=0_4eb677ad19-a97f04efe2-337259209 with a minor change to authentication, which I have included as comment in the stackoverflow post

Android unable to connect to a Hotspot created by another Android Device

We are building an Android App which will let it connect to other android devices via a Socket Connection through a Wifi Hotspot created in the Server Android Device.
For most of the cases, this works perfectly. However for some cases, no matter how many times we try, a device is not able to connect to a WiFi Hotspot. This issue is not device specific. A device which is able to connect now, may not be able to connect at some other time.
While we were desperately looking for workarounds, we realized that if we Switch on and off the Hotspot in the connector, then it connects immediately to a WiFi Hotspot it was not able to connect previously.
Can anyone help us understand why is this happening? Also, is there anyway we can replicate this without switching off the WiFi Radio(switching on the Hotspot switches the Radio off)?

Android restart bluetooth socket after crash?

I'm working on my first app for a school project. It receives and proccesses data received over bluetooth (PC with terminal and bluetooth module).
Everything works as it should but if something happens that wasn't expected, the app could crash. this is not a big deal but the Bluetooth connection remains connected although my program doesn't know that and can't work. **Is there a function to request the active bluetooth connection (like restarting a socket with the adress or something?)
I cant connect it the default way because the bluetooth discvery cant find the device anymore.
If i restart the phone everything works fine again.
I'm using the default bluetooth threads from the Android develeoper website. If anyone needs to see the code I can put it here.
When you are working with BluetoothSockets you can use yourBluetoothSocket.getRemoteDevice(); This wil get the BluetoothDevice this socket is connected to.
If there is no device connected, you can hardcode the MAC-adres of the device you want to connect to.
BluetoothDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(MAC-ADDRESS);
after this you can try to reconnect.

Testing app beetween real device and emulator via WiFi without router

I develop app which contains a client and a server side, so I need to test work between them. I have a real android device and I want android device to connects to emulator. I'm working at work sometimes(if I have free time of course) and at home. I have the WiFi router at home and I can connect to the real device by emulator(TCP listener running on the real device), but not vise versa(I don't know which exactly IP to use). But at work I have only hot-spot WiFi point without router. My android device connects to it fine. Even more ADB can connect to the device when adbWireless running on it. But it doesn't work, I can't connect to tcp listener in any cases. The difference between home and work is existence of WiFi router. Are there any solutions? If not why Android debug bridge(ADB) can connect to adbWireless? Thanks.
I solved the problem. I run tethering on my real device and run the server on it. Then I use a program Connection state viewer there is a link: https://play.google.com/store/apps/details?id=ru.nolesh.android.connectionstateviewer It helps me to find IP address. After that I start the emulator and the client side on it. So I connect to my server by given IP.

is it ok to connect 2 devices concurrently to connect Bluetooth in Android?

Iam connecting 3G phone for my Android device for internet connection and another Socket(SPP) for CAN signal receiving.Whenever I manually connect to the Bluetooth tethering via 3G phone, i can browse internet perfectly and speed is good.Whenever programmatically connect to the 3G connection, i couldn't browse internet.i checked in shell and observing that in my mobile 'device is connected' message displayed and E symbol appears.No problem for me to connect Socket.But I got problem to use 3G phone.For this iam using APN/DUN mode.I checked both but no use.Is there any performance issue here or anything wrong to connect different devices by using Bluetooth API in android.Why this happends while connecting Mobile programmatically.Please give me guidance.
Regards,
Rajendar
Yes, you can have several open connections at a time.
In fact, I've used my hands-free bluetooth on my phone, as it is connected to my ELM327 SPP device streaming at full speed. I didn't notice any hiccups.
As for losing connectivity when you are connected to multiple devices, it's most likely an issue with the DUN provider you're using.
Also it's worth stating that, on Verizon/3g phones, when you use the phone as a phone, it suspends all 3g data services until the call is terminated.
The way L2CAP defines the LT_ADDR allows connecting devices up to 7. Your connection problems is something else.

Categories

Resources