Titanium HTTPClient - TSL connections sometimes get "lost" von Android (not on iOS) - android

This is an very, very strange problem.
We got an app based on Titanium SDK (version 7.4.1 I think), which gets it's data via an API to from our servers. These connections are running with TSL and basically, it works. But: Some connections do not receive data, they just run into a timeout.
I did some debug on this and this resulted in an even more strange thing: The working connections work really fine, but the non-working doing strange things. App connects to the server, server sends ACK. After this, app sends a ClientHello and receives an ACK - but nothing follows. The app is waiting for the ServerHello until the connections times out. This is all from a tcpdump.
So I created the same dump on server side, and here it starts to get really strange: For the non-working connections, the initial handshake is there. But the ClientHello is not received by the server.
This leaves me baffled, because the app is getting an ACK for sent ClientHello. Who TF is sending this, when the server never received any? It's an VM within a larger cluster - maybe it's ACKed before it reaches the VM?
Because I mentioned Titanium as well: The problem ONLY occures on Android. The iOS version of the app (with same code) is not affected!
Any ideas from anyone? All input is highly appreciated.

Related

Flutter `SocketException: HTTP connection timed out` sometimes when app start

I have a Flutter application and it makes some HTTP requests to my server. However, once in a while (not sure when, but I have seen it several times a day), when I open my app, the HTTP requests that happen during the first few seconds all report the error of SocketException: HTTP connection timed out (the source code that throws this seems to be here). However, after the first few seconds, other HTTP requests will succeed.
I have tried hard reproducing it but failed. Usually this bug happens, when I put my phone there for some time and then open the app (but it is not a thing for sure; also in many cases such behavior will not trigger the bug). If the bug happens, and I close the app and reopen it immediately, it will run very well and the bug will not happen again.
I have also used Wireshark to try to look at the network packages. However, when I setup the environment as "my app (in my phone) connects to my computer with development server using wifi and http", that bug seems to never appear again. Only with the production environment "my app (in my phone) connects to a server in the cloud using https" that this bug happens. But in that case I cannot use Wireshark to look into the packages.
I know I do not provide a reproducible sample, but I really cannot find out any clues. I even cannot stably reproduce it :(
I would truly appreciate it for any suggestions!!!
I had faced this issue in one of my initial projects, which usually happens with HTTP package, I'll recommend you to try this package:
https://pub.dev/packages/dio
And if you are an android developer then you may know it is the best combination to use dio with retrofit
https://pub.dev/packages/retrofit

Android signalr network change timeout

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

UDP transmission stops after sometime

Ok, so here's my problem. I have an android app transmitting UDP packets to a PC (a java program which listens for the packets), based on user interactions with the android device. To keep things simple, let's say this is happening - the user taps the screen of the phone, and it sends a UDP packet with the coordinates of the point where the user tapped. The listener program receives and reads this packet, and outputs the string received, using System.out.println().
Now, what's happening is that the program works perfectly for the first few packets. Then it stops working, as in, the listener program on the desktop does not display any output. Now, the issue is probably with the transmission, as I have a text label on the app (for testing purpose) that displays what is being transmitted, so the transmission packet is definitely being built properly. But I have no idea on how to understand if this is a problem with sending the data (on the android device side), or receiving (on the desktop side). How can I find out what's wrong and solve this issue?
I have mostly worked with TCP transmission and all the UDP i have done are mostly Copy-Paste [:-)] or with APIs
For TCP, after transmission, I throw a debug message, which helps me to know that the transmission occurred properly. But in this case, your write will have to be blocking.
Also, you could use a Packet Tracer on your listener terminal to determine whether it is receiving the packets properly. The one I love is WireShark (I think its a fork of Ethereal). Its really easy to use. You tell it which interface to listen on and give a filter and it will list out the packets as and when they come.
However, if you are using Windows 7, you will need admin privileges.
Are you using native code or Java classes? I have tried both, and with the NDK (i.e. sockets written as C functions being called from Java) I have seen erratic behavior on the server side, mostly due to threading issues. Using the Java Socket class I have not had issues however. Moreover, if your Android app is the client, that should not be the problem. I would also use Wireshark to check whether the packets are reaching the PC.

Lost messages over XMPP on device disconnected

I'm trying to develop a turn base game over XMPP. ( The only solution I found for multiplatform game ). I can send messages without problems. If the other user isn't online, the server (OpenFire) save it for later deliver.
The problem cames when a device change the network ( change from 3g to WiFi, change 3g IP... ) or the device lost the network ( turn off 3g, wifi or lost connection ). The server thinks that the device is online and send the message but it ( obviusly ) never arrive, so packet is lost.
I know one solution. Implement ACK over my game protocol, but I don't like this idea to much. Do you have any other suggestion? I think this is a server problem. Do you know another server witch implements TCP or ACK?
Thank you!!
EDIT: I do that: Connect device to server. I turn down the 3G and WiFi connectivity to the device. Android and the server still thinking that the connection is alive.
http://issues.igniterealtime.org/browse/SMACK-331
PD: I ask to openfeint for they multiplayer api, but they didn't asnwer me...
Although BOSH will likely work in this case, another option is XEP-0198: Stream Management. This will allow you to have all of the performance of a fully-connected socket, along with quick reconnects, positive acking, and queuing while un-acked or disconnected in both directions.
Under some conditions TCP/IP is not reliable. This is why ACKs, message receipts, IQs or other extensions in XMPP can solve this problem.
I have done lots of mobile programming over the years, also often with Openfire. But I have not seen lost messages. So I assume that there is a problem in either the library you are using on Android, or the Openfire version you use.
Instead of using raw sockets you can also use BOSH:
http://xmpp.org/extensions/xep-0124.html
BOSH is based on WebRequests like Comet and works very well in environments where you switch or loose often the connection. It can keep the connection alive until your network is back and does not result in connection drops when one or more requests fail in a row.
I too came across this issue and been trying to figure out a proper way to get this resolved.
Problem for me is that I set the offline messages policy to "Always Store" and thus XEP-0184 doesn't really help out to determine if a message is not getting delivered to its receiver.
Providing this scenario:
- I have 2 users chatting, call them A and B
- A sends B a message while B's connection just got lost
- The message got dropped and A is not notified
- In this case A does not know that the message got dropped, it'll just assume that the message is delivered to the server, server will eventually deliver it to B
- B lose the message forever
So I temporarily put in a work around for this... i store all those messages that are not delivered (i.e. haven't receive the message delivery receipt) into a queue, then periodically (say, 6 minutes - it's the time when those dead connections got wiped) check every message of the queue to see if the intended recipient is "Online" AND the receipt's still not received... If it's the case, then I mark that message as "Failed delivery"
This is quite a terrible way to fix it (please advise if you have a better way of doing it). I think the best thing to do is to have the server to do this: if message failed to deliver and the offline message policy is "Always Store", then we store it to "ofoffline" for delayed delivery.
This is an old one, but I was solving such an issue recently. It helped me when I set the XMPP resource (the last part of full JID) to something reasonable, when building connection. Otherwise it will be random generated on each reconnect - and that changes the full JID.

Problems transfering data between an application and a server using TCP sockets [Android]

My development team and I, are working on an application that uses a sql database, we try to transfer a database from our application to a server using tcp sockets, we made some research about sockets, the server program is written on java language using netbeans, and the application is written on eclipse.
We made several conectivity tests between the application and server programs, using the android emulator, we tried to made it local (running both programs on the same computer) and the server conects with the application, but it doesn´t receive all packages, it receives aproximately 2Kb (we want to transfer a 25Kb file), the same happens when we run the server on other computer in the same network, we made some tests using wireshark to capture all the packagesincoming from the application to the server and viceversa, we´ve noticed that the server receives all the data, but first it receives a 2Kb packet, after that server application receives an end ack, and then, the application receives the missing packages, and then discards them.
We also made some conectivity tests using a coby kyros tablet instead of the emulator, and we have no problem, the application running on the tablet, sends all the data, and the server receives it.
We want know if there are an error on the emulator, and how to solve it.
Please help us or send us yout feedback
This sounds like you are running into a configuration problem with your emulator environment. Take a look at the network configuration info for the emulator.
The fact that its working fine from the actual device suggests to me you have an emulator network configuration issue. There could be a number of issues. I imagine that wireshark can show the packets reaching the machine the emulator is on, but that doesn't mean they are making it into the virtual network the emulator is in.
To verify you'll probably need to use something like
telnet localhost <emulator port>
network capture start
... run test ...
network capture stop
and then look at the capture file. That seems like it should capture your traffic inside the emulator environment to give you an idea of whats happening.

Categories

Resources