Android Question (SocketException) java.net.SocketException: Too many open files, error message

Status
Not open for further replies.

gacar

Active Member
In the questions I asked before (Here and here), I said that I got an error due to KVS. Then I completely removed KVS from my project. I am currently using firebasemessaging, which has no function, but still my program crashes after about 30 minutes (when I measured more carefully, I saw that it was about 30 minutes, not 10 minutes).

I am getting this error messages first but not crashing app

B4X:
(SocketException) java.net.SocketException: Too many open files

After this error message (java.lang.RuntimeException: Adding window failed) and crashed

B4X:
 .....
** Service (firebasemessaging) Start **
** Service (firebasemessaging) Start **
** Service (firebasemessaging) Start **
** Service (firebasemessaging) Start **
** Service (firebasemessaging) Start **
** Service (firebasemessaging) Start **
** Service (firebasemessaging) Start **
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
** Service (firebasemessaging) Start **
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
** Service (firebasemessaging) Start **
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
** Service (firebasemessaging) Start **
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
** Service (firebasemessaging) Start **
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
** Service (firebasemessaging) Start **
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
** Service (firebasemessaging) Start **
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
** Service (firebasemessaging) Start **
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
(SocketException) java.net.SocketException: Too many open files
 .....
java.lang.RuntimeException: Adding window failed
    at android.view.ViewRootImpl.setView(ViewRootImpl.java:652)
    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
    at android.widget.PopupWindow.invokePopup(PopupWindow.java:1378)
    at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1154)
    at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1121)
    at android.widget.Editor$HandleView.updatePosition(Editor.java:4427)
    at android.widget.Editor$PositionListener.onPreDraw(Editor.java:3077)
    at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2205)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6338)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
    at android.view.Choreographer.doCallbacks(Choreographer.java:686)
    at android.view.Choreographer.doFrame(Choreographer.java:621)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6161)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
Caused by: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
    at android.os.BinderProxy.transactNative(Native Method)
    at android.os.BinderProxy.transact(Binder.java:615)
    at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:828)
    at android.view.ViewRootImpl.setView(ViewRootImpl.java:640)
    ... 22 more
java.lang.RuntimeException: Unable to create service DemirHaber.Mobile.firebasemessaging: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3206)
    at android.app.ActivityThread.-wrap5(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1572)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6161)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
    at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
    at DemirHaber.Mobile.firebasemessaging.onCreate(firebasemessaging.java:34)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3196)
    ... 8 more
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference
    at anywheresoftware.b4a.shell.ShellConnector.sendControlMessage(ShellConnector.java:61)
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:124)
    ... 12 more

My FirebaseMessaging code here

B4X:
#Region  Service Attributes 
    #StartAtBoot: False
    
#End Region

Sub Process_Globals
    Private fm As FirebaseMessaging
    'Private KVS As KeyValueStore
    'Private xui As XUI 
End Sub

Sub Service_Create
    fm.Initialize("fm") 
End Sub

Public Sub SubscribeToTopics
    'fm.SubscribeToTopic("general") 'you can subscribe to more topics
End Sub

Sub Service_Start (StartingIntent As Intent)  
'    xui.SetDataFolder("kvs")
'    KVS.Initialize(xui.DefaultFolder, "kvs.dat")
'    If KVS.Get("BildirimlerAcik") <> Null Then
'        If KVS.Get("BildirimlerAcik") Then
'            If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
'            Sleep(0)
'            Service.StopAutomaticForeground 'remove if not using B4A v8+.
'        Else
'            StopService(Me) 
'        End If 
'    Else
'        KVS.Put("BildirimlerAcik", True)
'    End If 
'    KVS.Close
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
'    Log("Message arrived")
'    Log($"Message data: ${Message.GetData}"$)
    Dim n As Notification
    n.Initialize
    n.Icon = "icon"
    n.AutoCancel = True
    n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
    n.Notify(1) 
End Sub

public Sub Service_Destroy

End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The error has nothing to do with the code you posted.

n the questions I asked before (Here and here), I said that I got an error due to KVS
Posting the same question multiple times is the sure way not to get help. Especially when you haven't provided enough information in both posts.
I'm closing this thread as it too doesn't include enough information.
 
Upvote 0
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…