dlucic 1 Posted October 5 I have a problem when my andoroid device lost wifi and connection broke. I can not reestablished that in ordinary maner. My andorid application have TSQLConnection object that connects to DataSnap server application. Everything works fine until I issue network problem. When wifi temporarly lost connection TSQLConnection also lost connection and I get Socket error #103 when I try to open TClientDataSet and that is OK. When I try it once again it works fine. I supose my application successfuly reconnect and open the query. But when I tryed it for the third time I have Socket error # 104. And again. Once OK another time Socket error #104. There is no problems when wifi connection is stable. What should I do? Share this post Link to post
Olli73 4 Posted October 5 (edited) It is better to use a HTTP-/Rest-Server ... You could easily fill a client dataset on client in this way: On Server you make a Query and then via a provider you load it into a clientdataset. Out of that you can use a command to make XML or JSON of it. That XML/JSON you send (as a result of a get query from client) to the client and with a command you can generate a filled ClientDataSet on Client and work then with that. The other way, to update the database on server, could be a little bit more complex. Edited October 5 by Olli73 Share this post Link to post
dlucic 1 Posted October 6 Thank you but you did not understand me. I mada both server DataSnap service and client Android application. Datasnap service has connection to MS SQL Server. This is objects that I used on server side service application : On the other side, I have android application that connect's to my DataSnap server service through TSQLConnection and TDSProviderConnection. And everything works fine until I lost my wifi connection in a second. I am trying to find way to recover my android application without restarting it. So, my android appllication works fine and when wifi connection broke for a second I receive Socket error #103 when I try to open one of mine TClientDataSet's. If I try it one more time it works fine again. But when I try it for the third time I receive Socket error #104. And that goes in a round (good response, Socket error #104, good response, Socket error #104...) until I restarted my application. Share this post Link to post
Remy Lebeau 1396 Posted October 6 1 hour ago, dlucic said: So, my android appllication works fine and when wifi connection broke for a second I receive Socket error #103 when I try to open one of mine TClientDataSet's. If I try it one more time it works fine again. But when I try it for the third time I receive Socket error #104. And that goes in a round (good response, Socket error #104, good response, Socket error #104...) until I restarted my application. Why not simply catch the socket error and retry the failed operation? Share this post Link to post
dlucic 1 Posted October 6 That's exactly what I tried, buti it heppens exactly as I wrote. This is code on my login form. I have procedure KonektujSe where I connect to DataSnap server service and it works fine. Than I have some code in onClick method with try except. When error occures I call KonektujSe procedure again but it doesn't work. Share this post Link to post
Olli73 4 Posted October 6 I have no experience with such a setup, but I would try to use "TDSProviderConnection.AfterDisconnect" event to start a timer which tries every second to call a "TDSProviderConnection.Open" until "TDSProviderConnection.connected" is true again. As long as the timer runs you block all actions which load or save data from/to the server. Share this post Link to post
Remy Lebeau 1396 Posted October 6 7 hours ago, dlucic said: That's exactly what I tried, buti it heppens exactly as I wrote. This is code on my login form. I have procedure KonektujSe where I connect to DataSnap server service and it works fine. Than I have some code in onClick method with try except. When error occures I call KonektujSe procedure again but it doesn't work. I see only a single retry in that code. Have you tried reconnecting multiple times, perhaps with a small delay in between each attempt? Share this post Link to post
Cristian Peța 103 Posted October 7 (edited) On 10/6/2024 at 10:33 AM, dlucic said: DataSnap server service through TSQLConnection I suppose the TSQLConnection uses the DataSnap Driver. Then it is better to change TSQLConnection.Driver.CommunicationProtocol from default tcp/ip to http. TCP/IP connections are fragile over wifi. EDIT: CommunicationProtocol is in TSQLConnection.Params but can be changed also from TSQLConnection.Driver in object inspector. Edited October 7 by Cristian Peța Share this post Link to post