AndroidVideoCache icon indicating copy to clipboard operation
AndroidVideoCache copied to clipboard

How to reslove this problem- java.io.IOException: shutdown failed: ENOTCONN (Transport endpoint is not connected)

Open issacluo opened this issue 7 years ago • 9 comments

java.io.IOException: shutdown failed: ENOTCONN (Transport endpoint is not connected) E/HttpProxyCacheServer: HttpProxyCacheServer error com.danikula.videocache.ProxyCacheException: Error closing socket input stream at com.danikula.videocache.HttpProxyCacheServer.closeSocketInput(HttpProxyCacheServer.java:284) at com.danikula.videocache.HttpProxyCacheServer.releaseSocket(HttpProxyCacheServer.java:269) at com.danikula.videocache.HttpProxyCacheServer.processSocket(HttpProxyCacheServer.java:242) at com.danikula.videocache.HttpProxyCacheServer.access$200(HttpProxyCacheServer.java:52) at com.danikula.videocache.HttpProxyCacheServer$SocketProcessorRunnable.run(HttpProxyCacheServer.java:337) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:782) Caused by: java.io.IOException: shutdown failed: ENOTCONN (Transport endpoint is not connected) at java.net.PlainSocketImpl.socketShutdown(PlainSocketImpl.java:267) at java.net.AbstractPlainSocketImpl.shutdownInput(AbstractPlainSocketImpl.java:583) at java.net.Socket.shutdownInput(Socket.java:1566) at com.danikula.videocache.HttpProxyCacheServer.closeSocketInput(HttpProxyCacheServer.java:277) at com.danikula.videocache.HttpProxyCacheServer.releaseSocket(HttpProxyCacheServer.java:269)  at com.danikula.videocache.HttpProxyCacheServer.processSocket(HttpProxyCacheServer.java:242)  at com.danikula.videocache.HttpProxyCacheServer.access$200(HttpProxyCacheServer.java:52)  at com.danikula.videocache.HttpProxyCacheServer$SocketProcessorRunnable.run(HttpProxyCacheServer.java:337)  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)  at java.util.concurrent.FutureTask.run(FutureTask.java:266)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)  at java.lang.Thread.run(Thread.java:782)  Caused by: android.system.ErrnoException: shutdown failed: ENOTCONN (Transport endpoint is not connected) at libcore.io.Linux.shutdown(Native Method) at libcore.io.ForwardingOs.shutdown(ForwardingOs.java:176) at java.net.PlainSocketImpl.socketShutdown(PlainSocketImpl.java:265) at java.net.AbstractPlainSocketImpl.shutdownInput(AbstractPlainSocketImpl.java:583)  at java.net.Socket.shutdownInput(Socket.java:1566)  at com.danikula.videocache.HttpProxyCacheServer.closeSocketInput(HttpProxyCacheServer.java:277)  at com.danikula.videocache.HttpProxyCacheServer.releaseSocket(HttpProxyCacheServer.java:269)  at com.danikula.videocache.HttpProxyCacheServer.processSocket(HttpProxyCacheServer.java:242)  at com.danikula.videocache.HttpProxyCacheServer.access$200(HttpProxyCacheServer.java:52)  at com.danikula.videocache.HttpProxyCacheServer$SocketProcessorRunnable.run(HttpProxyCacheServer.java:337)  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)  at java.util.concurrent.FutureTask.run(FutureTask.java:266)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)  at java.lang.Thread.run(Thread.java:782)  09-07 15:45:26.669 125-125/? E/HWComposer: Invalid layer type change: SolidColor --> Device 09-07 15:45:26.686 125-125/? E/HWComposer: Invalid layer type change: SolidColor --> Device 09-07 15:45:26.701 669-788/? E/WindowManager: win=Window{89850a3 u0 com.gzcf.policeaffairop/com.gzcf.policeaffairop.activity.CzgcActivity EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true 09-07 15:45:26.703 125-125/? E/HWComposer: Invalid layer type change: SolidColor --> Device 09-07 15:45:26.807 199-13933/? E/FFMPEGExtractor: FFMPEGExtractor Failed open file (err = -13): http://127.0.0.1:36096/http%3A%2F%2F192.168.10.124%3A9290%2Ffileserver%2Ffile%2FdownloadFile.do%3Fid%3D9105b2a1-dcca-4d8d-8ba8-96618302bf9e

issacluo avatar Sep 07 '18 07:09 issacluo

me too

JanesenGit avatar Sep 07 '18 09:09 JanesenGit

I am facing this issue too in oreo devices

Faiyyaz avatar Sep 25 '18 05:09 Faiyyaz

Me too facing this issue while playing some of the videos. If anybody can be fixed this issue. Please help to solve this issue.

sivasonai avatar Apr 24 '19 14:04 sivasonai

me too when i seek the audio gei this exception

hxiaoyu1218 avatar May 02 '19 17:05 hxiaoyu1218

me too @danikula

onexuan avatar Apr 25 '20 07:04 onexuan

Reproducing

For me this error occurs while using ExoPlayer and seeking in the video to a part which hasn't been downloaded by the Proxy yet. This results in a situation where the ExoPlayer closes the current socket (which still receives data) and instead opens a new HTTP GET request with a Range: bytes=XXXXX- Header.

I investigated a bit and found out, that danikula implemented a fix in 2.5.0 for seeking in videos, see #21 and #17. And not surprisingly 2.5.0 fixes this problem and the above mentioned error does not happen (there are still some other errors, because ExoPlayer did close the socket). However in newer versions of AndroidVideoCache (>= 2.6.0) the above mentioned error occures. But in reality those are two different errors.

  1. Socket closing error
E/HttpProxyCacheServer: HttpProxyCacheServer error
    com.danikula.videocache.ProxyCacheException: Error closing socket input stream. Version: 2.7.0
        at com.danikula.videocache.HttpProxyCacheServer.closeSocketInput(HttpProxyCacheServer.java:285)
        at com.danikula.videocache.HttpProxyCacheServer.releaseSocket(HttpProxyCacheServer.java:270)
        at com.danikula.videocache.HttpProxyCacheServer.processSocket(HttpProxyCacheServer.java:243)
        at com.danikula.videocache.HttpProxyCacheServer.access$200(HttpProxyCacheServer.java:52)
        at com.danikula.videocache.HttpProxyCacheServer$SocketProcessorRunnable.run(HttpProxyCacheServer.java:338)
    Caused by: java.io.IOException: shutdown failed: ENOTCONN (Transport endpoint is not connected)
        at java.net.PlainSocketImpl.socketShutdown(PlainSocketImpl.java:283)
W/HttpProxyCacheServer: Failed to close socket on proxy side: shutdown failed: ENOTCONN (Transport endpoint is not connected). It seems client have already closed connection.
  1. Followed by the GET Range Request for the seeked video which produces the following exception
E/LoadTask: Unexpected exception loading stream
      java.lang.IllegalArgumentException: byteCount < 0: -157090173
        at com.android.okhttp.okio.RealBufferedSource.read(RealBufferedSource.java:47)
        at com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.read(Http1xStream.java:395)
        at com.android.okhttp.internal.Util.skipAll(Util.java:165)
E/HttpProxyCacheServer: HttpProxyCacheServer error
    com.danikula.videocache.ProxyCacheException: Error closing socket input stream. Version: 2.7.0
        at com.danikula.videocache.HttpProxyCacheServer.closeSocketInput(HttpProxyCacheServer.java:285)
        at com.danikula.videocache.HttpProxyCacheServer.releaseSocket(HttpProxyCacheServer.java:270)
        at com.danikula.videocache.HttpProxyCacheServer.processSocket(HttpProxyCacheServer.java:243)
    Caused by: java.io.IOException: shutdown failed: ENOTCONN (Transport endpoint is not connected)
        at java.net.PlainSocketImpl.socketShutdown(PlainSocketImpl.java:283)

Solution

Use version 2.5.0 (and add android.useNewApkCreator=false to gradle.properties if you get a build error) until @danikula finds out what is causing this problem.

@danikula could you please recheck if some of your changes from 2.5.0 were lost in the upgrade to 2.6.0?

MadTracki avatar Jun 05 '20 14:06 MadTracki

Any solutions to this error?

KryptKode avatar Jul 15 '20 08:07 KryptKode

@KryptKode I already used ExoPlayer and found that it already has an existing Caching implementation. Therefore it was an easy choice to switch to CachedDataSource in ExoPlayer.

See this StackOverflow thread for more information on this topic. (Unfortunately the ExoPlayer Documentation does not provide documentation about the wonderful Caching feature in this library)

MadTracki avatar Jul 15 '20 10:07 MadTracki

I fix this issue by down to version: 2.6.4

fengmingye avatar Nov 28 '22 07:11 fengmingye