MediaBrowser / Emby.ApiClient.Java

ApiClient allows Java apps to easily access the Emby API
http://emby.media
MIT License
20 stars 22 forks source link

Remote connections fail on subsequent android app opening. #14

Open DirtyJerz opened 9 years ago

DirtyJerz commented 9 years ago

Here's the long and short of it. On my local network, everything connects and runs great. When I try to connect from outside my local network, the app stalls after connection with a blank main screen. It's as if the app found the connection then instantly lost it. I think it's from the async nature of searching for the servers. Below is a grep'd ('/App') logcat so it's missing volley and other messages. I'll fire up Android studio and get a more complete logcat at a later time but I think this illustrate the issue.

I/App     ( 7971): 21:33:31.444 [main] INFO  App - Application Version: 2.2.38
I/App     ( 7971): 21:33:31.446 [main] INFO  App - Android Version: 5.1.1
I/App     ( 7971): 21:33:31.447 [main] INFO  App - Device: Nexus 6
I/App     ( 7971): 21:33:31.449 [main] INFO  App - Screen Width: 1440
I/App     ( 7971): 21:33:31.449 [main] INFO  App - Screen Height: 2392
I/App     ( 7971): 21:33:31.450 [main] INFO  App - Density: 3.5
I/App     ( 7971): 21:33:31.450 [main] INFO  App - DensityDpi: 560
I/App     ( 7971): 21:33:31.452 [main] INFO  App - Total Memory Available: 1917 MB
I/App     ( 7971): 21:33:31.453 [main] INFO  App - Max Memory usable per Application: 512 MB
I/App     ( 7971): 21:33:31.454 [main] INFO  App - Application object initialized
I/App     ( 7971): 21:33:31.459 [main] INFO  App - Dolby Audio Processing can't be instantiated on this device.
I/App     ( 7971): 21:33:31.468 [main] INFO  App - registerActivityLifecycleCallbacks is done.
I/App     ( 7971): 21:33:31.631 [main] INFO  App - onActivityResumed: com.mb.android.ui.main.ConnectionActivity
I/App     ( 7971): 21:33:31.632 [main] INFO  App - Activitys:[com.mb.android.ui.main.ConnectionActivity]
D/App     ( 7971): 21:33:31.741 [Thread-699] DEBUG App - Testing local device network connection
D/App     ( 7971): 21:33:31.743 [Thread-699] DEBUG App - Android device is connected to a network
D/App     ( 7971): 21:33:31.744 [Thread-699] DEBUG App - Entering initial connection workflow
D/App     ( 7971): 21:33:31.746 [Thread-699] DEBUG App - Getting saved servers via credential provider
D/App     ( 7971): 21:33:31.785 [Thread-699] DEBUG App - Scanning network for local servers
D/App     ( 7971): 21:33:31.788 [Thread-702] DEBUG App - mediabrowser.apiinteraction.discovery.ServerLocator>>> Request packet sent to: 255.255.255.255 (DEFAULT)
D/App     ( 7971): 21:33:31.803 [Thread-702] DEBUG App - mediabrowser.apiinteraction.discovery.ServerLocator>>> Request packet sent to: 192.0.0.4; Interface: v4-rmnet_data0
D/App     ( 7971): 21:33:31.806 [Thread-702] DEBUG App - mediabrowser.apiinteraction.discovery.ServerLocator>>> Done looping over all network interfaces. Now waiting for a reply!
D/App     ( 7971): 21:33:32.803 [Thread-702] DEBUG App - Server discovery timed out waiting for response.
D/App     ( 7971): 21:33:32.804 [Thread-702] DEBUG App - Found 0 servers
D/App     ( 7971): 21:33:32.824 [Thread-702] DEBUG App - Looping through server list
D/App     ( 7971): 21:33:32.825 [Thread-702] DEBUG App - Testing local device network connection
D/App     ( 7971): 21:33:32.826 [Thread-702] DEBUG App - Android device is connected to a network
D/App     ( 7971): 21:33:32.828 [Thread-703] DEBUG App - Waking server: Oakington's Media Browser, Id: 02bd66f7a58848298b0ba8c12ab7ff56
D/App     ( 7971): 21:33:32.829 [Thread-703] DEBUG App - Sending WakeOnLan over broadcast address. Mac: 10-C3-7B-50-8D-11, Port: 9
D/App     ( 7971): 21:33:32.832 [Thread-702] DEBUG App - Adding request to queue: http://myserver.co:8096/mediabrowser/system/info/public?format=json
I/App     ( 7971): 21:33:33.436 [main] INFO  App - Response received from: http://myserver.co:8096/mediabrowser/system/info/public?format=json
D/App     ( 7971): 21:33:33.463 [main] DEBUG App - Adding request to queue: http://myserver.co:8096/system/info?format=json
I/App     ( 7971): 21:33:33.642 [main] INFO  App - Response received from: http://myserver.co:8096/system/info?format=json
D/App     ( 7971): 21:33:33.668 [main] DEBUG App - Adding request to queue: http://myserver.co:8096/mediabrowser/users/2ec276a2642e54a19b612b9418a8bd3b?format=json
I/App     ( 7971): 21:33:33.830 [main] INFO  App - Response received from: http://myserver.co:8096/mediabrowser/users/2ec276a2642e54a19b612b9418a8bd3b?format=json
D/App     ( 7971): 21:33:33.915 [main] DEBUG App - Adding request to queue: http://192.168.0.121:8096/mediabrowser/Sessions/Capabilities/Full
D/App     ( 7971): 21:33:33.916 [main] DEBUG App - Creating ApiWebSocket
D/App     ( 7971): 21:33:33.917 [main] DEBUG App - Connecting to web socket url: ws://192.168.0.121:8096/mediabrowser?api_key=f0d9addd98ac4bc580db3abd0c7a749d&deviceId=32b73275e471074f
I/App     ( 7971): 21:33:33.925 [main] INFO  App - **** SIGNED IN ****
D/App     ( 7971): 21:33:33.935 [main] DEBUG App - ensuring is_first_run is now false
I/App     ( 7971): 21:33:33.948 [main] INFO  App - proceeding to mobile homescreen
I/App     ( 7971): 21:33:34.063 [main] INFO  App - ccl_VideoCastManager: New instance of VideoCastManager is created
I/App     ( 7971): 21:33:34.156 [main] INFO  App - HomeScreen Activity: onCreate
I/App     ( 7971): 21:33:34.162 [main] INFO  App - onActivityResumed: com.mb.android.ui.mobile.homescreen.HomescreenActivity
I/App     ( 7971): 21:33:34.163 [main] INFO  App - Activitys:[com.mb.android.ui.main.ConnectionActivity, com.mb.android.ui.mobile.homescreen.HomescreenActivity]
I/App     ( 7971): 21:33:34.216 [main] INFO  App - NewItemsFragmentonResume
I/App     ( 7971): 21:33:34.221 [main] INFO  App - NewItemsFragmentfinish onResume
I/App     ( 7971): 21:33:34.222 [main] INFO  App - FavoritesFragment onCreateView() reached
I/App     ( 7971): 21:33:34.230 [main] INFO  App - FavoritesFragment finish onCreateView()
I/App     ( 7971): 21:33:34.230 [main] INFO  App - UpNextFragment: onCreateView
I/App     ( 7971): 21:33:34.235 [main] INFO  App - UpNextFragmentFinish onCreateView
I/App     ( 7971): 21:33:34.236 [main] INFO  App - FavoritesFragmentonResume
I/App     ( 7971): 21:33:34.241 [main] INFO  App - FavoritesFragmentfinish onResume
I/App     ( 7971): 21:33:34.241 [main] INFO  App - UpNextFragmentonResume
I/App     ( 7971): 21:33:34.243 [main] INFO  App - UpNextFragmentfinish onResume
I/App     ( 7971): 21:33:34.779 [main] INFO  App - onActivityStopped: com.mb.android.ui.main.ConnectionActivity
I/App     ( 7971): 21:33:34.780 [main] INFO  App - Activitys:[com.mb.android.ui.mobile.homescreen.HomescreenActivity]
I/App     ( 7971): 21:33:34.780 [main] INFO  App - isAppInBackground:false Activitys:[com.mb.android.ui.mobile.homescreen.HomescreenActivity]
E/App     ( 7971): 21:34:04.019 [main] ERROR App - VolleyError com.android.volley.TimeoutError: nullcom.android.volley.TimeoutErrorcom.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:146)com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
E/App     ( 7971): 21:34:04.218 [main] ERROR App - VolleyError com.android.volley.TimeoutError: nullcom.android.volley.TimeoutErrorcom.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:146)com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
E/App     ( 7971): 21:34:04.284 [main] ERROR App - VolleyError com.android.volley.TimeoutError: nullcom.android.volley.TimeoutErrorcom.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:146)com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)java:146)lley.TimeoutError: null
E/App     ( 7971): 21:34:04.301 [main] ERROR App - Navigation Menu: Error getting library contents
E/App     ( 7971): 21:34:34.127 [main] ERROR App - VolleyError com.android.volley.TimeoutError: nullcom.android.volley.TimeoutErrorcom.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:146)com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
I/App     ( 7971): 21:34:34.128 [main] INFO  App - NewItemsFragment: error getting new items
E/App     ( 7971): 21:34:34.314 [main] ERROR App - VolleyError com.android.volley.TimeoutError: nullcom.android.volley.TimeoutErrorcom.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:146)com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
I/App     ( 7971): 21:34:34.319 [main] INFO  App - ********* ON ERROR *********
E/App     ( 7971): 21:34:34.399 [main] ERROR App - VolleyError com.android.volley.TimeoutError: nullcom.android.volley.TimeoutErrorcom.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:146)com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
E/App     ( 7971): 21:34:34.403 [main] ERROR App - VolleyError com.android.volley.TimeoutError: nullcom.android.volley.TimeoutErrorcom.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:146)com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
I/App     ( 7971): 21:34:34.407 [main] INFO  App - ********* ON ERROR *********
E/App     ( 7971): 21:35:41.246 [Thread-711] ERROR App - Web socket error.java.net.ConnectExceptionlibcore.io.IoBridge.connect(IoBridge.java:124)libcore.io.IoBridge.connect(IoBridge.java:110)java.nio.SocketChannelImpl.connect(SocketChannelImpl.java:199)org.java_websocket.client.WebSocketClient.interruptableRun(WebSocketClient.java:210)org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:188)java.lang.Thread.run(Thread.java:818)caused by android.system.ErrnoExceptionlibcore.io.Posix.connect(Native Method)libcore.io.BlockGuardOs.connect(BlockGuardOs.java:111)libcore.io.IoBridge.connectErrno(IoBridge.java:137)libcore.io.IoBridge.connect(IoBridge.java:122)libcore.io.IoBridge.connect(IoBridge.java:110)java.nio.SocketChannelImpl.connect(SocketChannelImpl.java:199)org.java_websocket.client.WebSocketClient.interruptableRun(WebSocketClient.java:210)org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:188)java.lang.Thread.run(Thread.java:818)
I/App     ( 7971): 21:35:41.249 [Thread-711] INFO  App - Web socket connection closed.

You can see that after the line

D/App     ( 7971): 21:33:32.829 [Thread-703] DEBUG App - Sending WakeOnLan over broadcast address. Mac: 10-C3-7B-50-8D-11, Port: 9

it finds the correct address and authenticates, but the url is changed back to the intranet IP. I tried tracing the log through the API in IntelliJ but ran out of time. Posting here to see if you have a quick fix.

Thanks.

LukePulverenti commented 11 months ago

This repository is outdated and archived! You can find up-to-date client libraries in the new Emby.ApiClient Repository