Hi everyone I have a question for you. I have a project that is using xamarin forms and in this project we are using the signalr client. Whenever I switch from Wi-Fi to cellular data my signal are times out. However the weird thing is that no statechanged events ever fire on a client side not even the disconnect, and I can still send messages with the proxy to other clients but it doesn't receive messages from the other clients. I had a question last week where servicestack was timing out when I switched from Wi-Fi to mobile and the solution was to put a connection header in the request that was set to close. I tried that with the signalr connection but it doesn't work. I've also tried to use the project modernhttpclient and that doesn't work either. On the server side I've even tried saying the keepalive to know so that way it only uses the connection timeout and the disconnect timeout.
Some other weird information about this problem is that it doesn't happen on all Android devices. It seems to work on the Samsung and a different Android device possibly a Nexus device. The reason I know this is that my coworkers have these phones and it works perfectly fine for them. However my device, which is a samsung galaxy s6 edge comma does not work with the code that was implemented for reconnecting when did not work changes
Related
Hello there long time reader of Stack Overflow but first time poster,
I am a bit new to android development but we decided to build a Xamarin.Forms app which consumes our ASP.NET REST service. When running the app on an emulator on my computer, connected via ethernet, I am able to connect to the service. However, when running on a tablet or phone that is connected on our work wifi, the connection just hangs and times out.
Interesting enough, when the device is switched to mobile data it can connect to the endpoints again, and iPhones can connect to the endpoints on mobile data or wifi.
I'm curious what I'm missing here. Please let me know what you think or additional information I should include.
While this thread has been opened for some time, we have found our problem resolved: it was a mixture of our network support changing some settings on our routers (though I can unfortunately not remember what settings) and also our tablets do a system update.
I am not sure which of these factors was the cause of our success now but the issue is done. I just wanted to post this in case anyone else ran into something similar.
I really need help here...
I have a simple Android application that connects to my sever to fetch data over HTTPS.
Everything is working fine up until i connected to the same server from another device (iOS or Android). I am starting to get timeouts or connection refused or other errors depending on the library that I use (sometimes SSL handshake)
I tried 2 android app on the same router - fails
I tried Volley, Retrofit, plain http library - fails
if one device is connected via cellular network and one on wifi, it is working fine. However, i have seen cases that it fails even using 2 devices connected to cellular network and not wifi.
It is easy to reproduce. one app is working fine. as soon as i do an operation on the other device. the first app will not be able to connect.
iOS app using the same api/server is working fine. no failures
I ran wireshark on the android app during failure and received the following:
70 47.073286 10.0.0.1 10.0.0.138 ICMP 120 Destination unreachable (Port unreachable)
Seems like port issues. I am not sure anymore if this is a server issue or a client issue.. iOS app works fine. no issues. Only Android.
I tried:
System.setProperty("http.keepAlive", "false");
I tried setting an http header "connection :close" nothing works...
Any idea would be appreciated...
Same problem here . When my ios device connect to allstar heroes or fun run application the android device cant connect anymore . I cant find s fix for that . My router is tp link dir 615 . Maybe the problem is frpm router .
At the end of the day, it was server side issue. the IT guy gave me the following info: "incorrect flag on the tcp kernel settings" "Reuse connection" that is all I have for you. hope it can help someone else
I had the same problem. The issue seemed to be when the app tried to access ports in TIME_CLOSE here is a great explanation how this happen, changing the tcp kernel to Reuse connection, might solve the problem since the server will try to re-use those connection in TIME_CLOSE again. but it must be a solution from the client side to avoid the connection to get stuck. in my case I was trying to create connection from multiples activities and i guess they, somehow, competed for opening and closing the connections, i solved the issue using a single activity to make the connection to the server.
hope this is useful to someone.
Had exact the same issue and spent a lot of time investigating, nothing helped including "Reuse connection" flag, tried also to disable tcp_timestamp, tcp_tw_reuse, tcp_tw_recycle and enable vm safe mode for the app as suggested here:
https://github.com/square/okhttp/issues/903
https://github.com/square/okhttp/issues/1037
https://github.com/square/okhttp/issues/1518
but all in vein.
Further more, the very strange thing was that I had two different instances/servers which I made exactly the same in order to track down the issue and one server didn't have any issues.
So in the end:
Instance reboot solved problem with connections.
(or just need to restart networking service)
(c) My server/instance admin
I have an Android app which, as part of its core functionality, makes ASP.NET WebService calls. I have authored the app successfully using ksoap2 to make the calls and it does what I need it to.
Our client reports that they have found some phones where the app does not work. Namely, during some of the WebService calls it appears to time out. This befuddled me because it works perfectly on the handful of phones we've tested it with here in my office.
One of the phones the client reported having an issue with was the Samsung Galaxy S2 on Sprint (the other phone they reported was either a Samsung Galaxy S or a Samsung Galaxy S3 - real similar phone, in other words). As luck would have it I was able to hunt down an employee in the company who had a Samsung Galaxy S2 on Sprint and was willing to let me borrow it. And I was able to re-create the issue. Attached to Eclipse it appears to be getting a SocketTimeoutException. Not every time, but more often than not.
As part of my testing, I connected the phone to a MiFi on Verizon. So, essentially I was taking it off of Sprint's network and putting it on Verizon's. When I did this, the app worked as expected, no timeouts.
At first I thought maybe Sprint's network was just bad but that seemed unlikely seeing as how my client is on the other side of the country from me so unless their network is consistently bad I doubt that's the case.
But what I noticed is - in the status bar of the phone, when connected to Sprint, I saw 3G and 4G icons, and they appeared to be switching back and forth (the way they're laid out, they both appear, just turned off/on right next to each other). When I was connected to the MiFi, as far as the phone knows or cares I'm connected to a Wi-Fi point.
So what I wonder is - could it be that the phone is "switching" back and forth between the 3G and 4G networks and the response to the webservice call is getting lost? On the iPhone if you make a request for a webpage in Safari with your phone on the 3G network (for example) and the phone then finds a Wi-Fi point to connect to and switches over, you still get the webpage on your device even after it connects to Wi-Fi. I presume that the OS is allowing the 3G calls to finish out before switching that network off.
Could something that Samsung has done with the OS for the Galaxy S* line be causing my responses to be getting lost? And if so, is there something I can do about it to prevent this from happening? Is there a way to figure out what network connections are still alive?
UPDATE: See my answer below, this question's premise turned out not to be the reason, although it does occur to me that I forgot to point out that the particular calls that fail or timeout contain base64-encoded images and so they're larger than normal webservice calls.
For what it's worth, the answer appears to be "no"
I used the code from this blog entry which allows me to monitor when a network connection change occurs and I was able to verify that the behavior occurs even when the network connection doesn't change.
So it does appear that for whatever reason this particular combination (Sprint/Samsung Galaxy S or S2) doesn't like what I'm doing.
One thing I forgot to mention is that I'm sending a Base64-encoded image across the web service call so the size may have some relation to it but I can't figure out what the issue is exactly.
I am facing a rather weird problem with my android app. It is a very basic app which connects to a server and posts requests.
When the phone is switched on initially, and the app is started with only a 3G connection - the server connection times-out each and every time. The moment i connect to a wifi network it works. And to top it off - if i switch back to 3G after this , it works fine. I am very confused as to what is going on.
Do I need to turn on some parameter in order for the app to work without wifi and only 3G in the first try? Any insight would be appreciated :)
I'm attempting to adapt the BluetoothChat example that comes with the SDK to a single-server, multiple-client configuration. I'm having issues and hope someone can help.
I've created two distinct apps, a server and a client, rather than have a single app function as both server and client, as in the example. So the upon starting the app, the server creates a bluetooth service, which creates a new AcceptThread, which listens for incoming connections. I made a couple of modifications to the example code so that the AcceptThread continues to listen, even after the first connection is made (the example stops listening after the one connection is made, because it only needs to establish connections between two devices). I created an ArrayList to handle the multiple connections. Each time a new connection is attempted from a remote device, a new ConnectedThread is created and added to the list.
The first client connects just fine.
When the second client attempts to connect, the connection fails. The log output is:
D/BluetoothEventLoop( 140): Device property changed: <device address> property: Connected value: true
I/BluetoothService( 140): ACL connected, mAclLinkCount = 2
D/BluetoothEventLoop( 140): Device property changed: <device address> property: Connected value: false
I/BluetoothService( 140): ACL disconnected, mAclLinkCount = 1
So it looks like the second connection attempt is successful, but then it is immediately disconnected. This looks like it's happening at a low level, outside anything the code is handling. This happens with a number of different types of test devices, so I don't think it's due to a particular firmware or hardware issue.
Can anyone help with this?
Also, can anyone point to an example of a server->multiple client connection example using bluetooth with Android? I came across an Air Hockey example:
http://code.google.com/p/apps-for-android/source/browse/#svn%2Ftrunk%2FBTClickLinkCompete%2Fsrc%2Fnet%2Fclc%2Fbt
But this project is very glitchy on my test devices and the actual game won't display properly. Does anyone know if there is an example of BluetoothChat extended to handle multiple connections?
UPDATE:
In attempting to solve this issue, I believe I have successfully extended the official Android Bluetooth Chat example to work with a server connecting to multiple clients.
I've uploaded my modifications to github here.
One device acts as the server by selecting "Menu>Make discoverable". Each client then connects by selecting "Menu>Connect a device". I was successfully able to connect my Motorola Droid and HTC Eris as clients to my Samsung Galaxy Tab 10.1". Each message sent from a client displays only on the server. A message sent from the server displays on all clients.
This was a tedious process getting it to work at all. Connectivity with the HTC devices is sporadic, though. I've read elsewhere that bluetooth on HTC is buggy, so I'm chalking it up to that.
Hopefully someone else will find this example useful. If you have any questions, suggestions, or other feedback, please let me know.
I tested your code. As, you said connecting HTC as master was a problem. I made Samsung S3 as master and HTC as client. it worked. But i tried again with a Sony Ericsson phone. No other device could successfully act as master.
S3 has Blutooth version 4.0 other have earlier version. Do you think the problem is because of Bluetooth stack?
I need to use this concept in a project where the devices will be custom made. Trying to find out weather the problem is related to vendors ( HTC, Sony) or its related to bluetooth stack. and i don't know how to find out. This is not documented. :(
Has anyone faced this?