Which mysql timeout do I must modify? - java

I've set up on my Raspberry Pi a Glassfish server (4) and a MySQL, to launch my webservices for my Android Application.
Everything is okay after a lot of problems !
But one question stay in my mind for me, why every day I'm trying to execute a query with my app, I must restart my glassfish to have a result (I have a 500 Internal Server Error).
I've searched on the net, and I think it's a timeout from MySQL, who close the connection between him and Glassfish, so I want to know what I must doing to solve this problem ?
Thanks by advance !
EDIT
Stack Trace :
example.webservices.exceptions.ServiceException: L'appel au webservice a rencontré une erreur 500 : could not execute query
at example.webservices.accessservice.UserAccessService.isUserExists(UserAccessService.java:52)
at example.androidapp.asynctasks.VerifyUserTask.doInBackground(VerifyUserTask.java:38)
at example.androidapp.asynctasks.VerifyUserTask.doInBackground(VerifyUserTask.java:20)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)

Related

Software caused connection abort Client receive

I'm making an app in Android studio and I'm getting an IOException which is unpredictable nor have I managed to replicate it.
W/TcpProtocolLayer: Connection to /x.x.x.x:x closed.
W/System.err: java.io.IOException: Software caused connection abort
W/System.err: at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
W/System.err: at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
W/System.err: at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
W/System.err: at sun.nio.ch.IOUtil.read(IOUtil.java:192)
W/System.err: at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:421)
W/System.err: at x.x.protocol.layer.TcpProtocolLayer.receive(TcpProtocolLayer.java:254)
W/System.err: at x.x.protocol.layer.TcpProtocolLayer.receive(TcpProtocolLayer.java:201)
W/System.err: at x.x.protocol.layer.DatagramProtocolLayer.receive(DatagramProtocolLayer.java:133)
W/System.err: at x.x.protocol.ProtocolStack.receive(ProtocolStack.java:190)
W/System.err: at x.x.protocol.Socket.receive(Socket.java:85)
I've been trying to wrap my head around it and I just can't seem to understand why this would happen, for legal reasons I can't show the code where it's happening but I can describe it.
The phone sends a message to a server and the server responds. This part is always successful and never fails. Then the phone waits for the server to send another message for a confirmation, and this is where it the exception happens. It might throw the exception instantly it might throw it after 10 seconds. I should also say that 90% of the time the code works just fine and no exception is thrown and it processes the information just fine. Then the 10% of the unpredictable attempts this happens and breaks the app completely. I've watched out for it not to be a Async Thread error ,and I've concluded it isn't and the Socket is opened at the moment of this happening. If anyone has any answer I'd be happy to hear it because this problem has been haunting me for a month already and I can't fix it

java.net.SocketTimeoutException at peak traffic on Production

We have been facing this issue on Prodcution. Now this issue occurs whenever a notification is rolled out to all the Mobile Apps and Desktop Apps. In the notification one image is there which is cached at CDN(Akamai). So a lot of users are getting the following exception. I tried to figure out the issue but a lot of people say it might be due to
network issue on the device but my question is DNS of XXXX.XXXX.com has been resolved to akamai ip (117.239.141.27). So, that should not be a problem. Moreover I had a work with Akamai guys they couldn't find any issue at their end. So, I have following questions:
1) How do i figure out what is causing the issue? Secondly, does anyone has faced the similar issue on production at peak traffic?
2) As mentioned in the below stack track which i got from crashlytics. In few cases we are getting private client ip (192.168.1.33) why is it so?
Shouln't public ip of client should be logged in the crashlytics.
Caused by java.net.SocketTimeoutException: failed to connect to XXXX.XXXX.com/117.239.141.27 (port 80) from /192.168.1.33 (port 50974) after 15000ms
at libcore.io.IoBridge.connectErrno(IoBridge.java:185)
at libcore.io.IoBridge.connect(IoBridge.java:129)
at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:137)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
at java.net.Socket.connect(Socket.java:621)
at com.android.okhttp.internal.Platform.connectSocket(Platform.java:145)
at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:1416)
at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:1368)
at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:219)
at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:142)
at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:104)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:392)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:325)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:488)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:434)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:565)
at com.squareup.picasso.UrlConnectionDownloader.load(UrlConnectionDownloader.java:125)
at com.squareup.picasso.NetworkRequestHandler.load$71fa0c91(NetworkRequestHandler.java:6)
at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:72)
at com.XXXXX.XXXXX.utils.AppNotificationHandler.getTabCategoryIdForScreen(AppNotificationHandler.java:82)
at com.XXXXX.XXXXX.utils.AppNotificationHandler.handleExtras(AppNotificationHandler.java:806)
at com.XXXXX.XXXXX.fcm.FCMIntentService.onMessageReceived(FCMIntentService.java:112)
at com.google.firebase.messaging.FirebaseMessagingService.zzd(FirebaseMessagingService.java:394)
at com.google.firebase.iid.zzg.run(zzg.java:26)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.android.gms.common.util.concurrent.zza.run(zza.java:7)
at java.lang.Thread.run(Thread.java:764)

java.lang.SecurityException: Binder invocation to an incorrect interface on Android 6

Recently started getting crashes due to java.lang.SecurityException: Binder invocation to an incorrect interface in our app which only happens on 6.0 and 6.0.1 OS.
The stack trace is pulled from a crash reporting service and could not be replicated locally on any of the Android 6 devices.
The app uses a 'Service' which calls 'startForeground' and the stack trace seems to point to that method call.
java.lang.SecurityException: Binder invocation to an incorrect interface
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at android.app.ActivityManagerProxy.setServiceForeground(ActivityManagerNative.java:4487)
at android.app.Service.startForeground(Service.java:652)
at com.anghami.audio.MusicService.J(MusicService.java:3517)
at com.anghami.audio.MusicService.b(MusicService.java:2676)
at com.anghami.audio.MusicService.F(MusicService.java:2647)
at com.anghami.audio.MusicService.a(MusicService.java:2421)
at com.anghami.audio.MusicService_.a(MusicService_.java:21)
at com.anghami.audio.MusicService_$4.a(MusicService_.java:214)
at org.androidannotations.api.a$a.run(BackgroundExecutor.java:401)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
The problem occurred when .Aidl file in client side were placed in wrong location.
the .Aidl file must be placed in a package of the same name as server side in the client's src folder.

SSL connection using pgjdbc-ng as Java driver for Postgres

I'm facing a great problem in connecting to a Postgres database using https://github.com/impossibl/pgjdbc-ng/. I need this lib because I need to get asynchronous notification from the database.
I'm trying to connect to a remote database using SSL an I'm doing this:
Class.forName("com.impossibl.postgres.jdbc.PGDriver");
String url = "jdbc:pgsql://host:5432/db"
+ "?ssl.mode=Require";
Connection conn = DriverManager.getConnection(url, "username", "pwd");
But, when I try to do that I get an IllegalStateException. This is the stack trace:
java.sql.SQLException: Connection Error: java.lang.IllegalStateException
at com.impossibl.postgres.jdbc.ConnectionUtil.createConnection(ConnectionUtil.java:189)
at com.impossibl.postgres.jdbc.PGDriver.connect(PGDriver.java:77)
at com.impossibl.postgres.jdbc.PGDriver.connect(PGDriver.java:52)
at java.sql.DriverManager.getConnection(DriverManager.java:179)
at it.polito.mobile.testpostgres.MainActivity$1.doInBackground(MainActivity.java:60)
at it.polito.mobile.testpostgres.MainActivity$1.doInBackground(MainActivity.java:35)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.io.IOException: java.lang.IllegalStateException
at com.impossibl.postgres.protocol.v30.ProtocolFactoryImpl.translateConnectionException(ProtocolFactoryImpl.java:285)
at com.impossibl.postgres.protocol.v30.ProtocolFactoryImpl.connect(ProtocolFactoryImpl.java:199)
at com.impossibl.postgres.protocol.v30.ProtocolFactoryImpl.connect(ProtocolFactoryImpl.java:90)
at com.impossibl.postgres.system.BasicContext.<init>(BasicContext.java:130)
at com.impossibl.postgres.jdbc.PGConnectionImpl.<init>(PGConnectionImpl.java:185)
at com.impossibl.postgres.jdbc.ConnectionUtil.createConnection(ConnectionUtil.java:180)
... 11 more
Caused by: java.lang.IllegalStateException
at io.netty.handler.ssl.SslHandler$LazyChannelPromise.executor(SslHandler.java:1491)
at io.netty.util.concurrent.DefaultPromise.checkDeadLock(DefaultPromise.java:388)
at io.netty.util.concurrent.DefaultPromise.awaitUninterruptibly(DefaultPromise.java:283)
at io.netty.util.concurrent.DefaultPromise.syncUninterruptibly(DefaultPromise.java:225)
at io.netty.util.concurrent.DefaultPromise.syncUninterruptibly(DefaultPromise.java:32)
at com.impossibl.postgres.protocol.v30.ProtocolFactoryImpl.connect(ProtocolFactoryImpl.java:132)
... 15 more
Before, I was using the standard library org.postgresql.Driver and everything worked fine...
Does anybody know how to help me?
Thank you so much!
Marco

Error in testing application on android device after connecting to android studio via wifi

I did follow this Connect to wifi tutorial and i was able to connect my phone to my desktop through wifi(router) and i am able to test almost all application wirelessly except those require JSON parsing. I am using wamp server and it is running but i am getting forbidden error.
This is the error in logcat. Can anyone tell me how shall i get rid of this error??
Also in my source code of the application, i did add the ip address of my desktop like this 192.168.0.105/test/stock.php instead of 10.10.0.2
My application works perfectly on the emulator but i am not able to run it on the device.
04-25 20:07:11.172 11847-11874/com.e.myapplication I/System.out﹕
ERROR : Forbidden 04-25 20:07:11.172 11847-11874/com.e.myapplication
I/System.out﹕ error 04-25 20:07:11.172
11847-11847/com.e.myapplication E/log_tag﹕ Error parsing data
org.json.JSONException: Value error of type java.lang.String cannot be
converted to JSONArray
Value error of type java.lang.String cannot be converted to JSONArray
means that you probably try to map something like this :
name="value"
to an array.
So your Json is wrongly formatted, you must have something like this :
name=["value"]
Since your app works correctly in the emulator, it's probably a communication error. The error you see is certainly the consequence of something else. Look at previous logs and log the json string you are trying to parse. (I'm pretty sure it is not at all what you expect)
I managed to solve the problem changing a setting in the Apache httpd.conf.
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
I changed it to
Order Deny,Allow
Allow from all
Allow from 127.0.0.1
And now my mobile can access the web service.

Categories

Resources