java.io.IOException: Connection closed

Java.net JIRA | rundgrent | 1 year ago
  1. 0

    I have a small image sending application that works ok with small files, but fails when working with bigger ones. Wondering if this is some kind of setting somewhere or what. I get almost same kind of error in both cases (running as standalone or deployed in Application server. The image is sent by a client (JavaFX) application and it is received on the server (and stored there as a file to verify that it is correct). Then the file is sent to all connected clients where it is displayed. Error I get with bigger files is as follows: {code}2015-12-01 15:35:15,694 [grizzly-nio-kernel(2) SelectorRunner] INFO com.volvo.adt.websocketserver.WebsocketEndPointImage.onClose() - Client disconnected ... removing from session TyrusSession{uri=/websocket/images, id='e9251ffa-8de2-4069-9db5-5b1797871146', endpointWrapper=TyrusEndpointWrapper{endpointClass=null, endpoint=org.glassfish.tyrus.core.AnnotatedEndpoint@764e76ff, contextPath='/websocket', endpointPath=/websocket/images, encoders=[CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.NoOpTextCoder, coder=org.glassfish.tyrus.core.coder.NoOpTextCoder@4225658e, type=class java.lang.String}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.NoOpByteBufferCoder, coder=org.glassfish.tyrus.core.coder.NoOpByteBufferCoder@27109b6f, type=class java.nio.ByteBuffer}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.NoOpByteArrayCoder, coder=org.glassfish.tyrus.core.coder.NoOpByteArrayCoder@66854a9f, type=class [B}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.ToStringEncoder, coder=org.glassfish.tyrus.core.coder.ToStringEncoder@63f9213e, type=class java.lang.Object}], decoders=[CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$BooleanDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$BooleanDecoder@a1931da, type=class java.lang.Boolean}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$ByteDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$ByteDecoder@29f10815, type=class java.lang.Byte}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$CharacterDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$CharacterDecoder@65ec7e06, type=class java.lang.Character}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$DoubleDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$DoubleDecoder@4fb65354, type=class java.lang.Double}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$FloatDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$FloatDecoder@c623c99, type=class java.lang.Float}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$IntegerDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$IntegerDecoder@2df23ca0, type=class java.lang.Integer}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$LongDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$LongDecoder@2be87b56, type=class java.lang.Long}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$ShortDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$ShortDecoder@56b9b18c, type=class java.lang.Short}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.NoOpTextCoder, coder=org.glassfish.tyrus.core.coder.NoOpTextCoder@4ba2d936, type=class java.lang.String}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.NoOpByteBufferCoder, coder=org.glassfish.tyrus.core.coder.NoOpByteBufferCoder@7789fbde, type=class java.nio.ByteBuffer}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.NoOpByteArrayCoder, coder=org.glassfish.tyrus.core.coder.NoOpByteArrayCoder@1f530cb2, type=class [B}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.ReaderDecoder, coder=org.glassfish.tyrus.core.coder.ReaderDecoder@47dfb05, type=class java.io.Reader}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.InputStreamDecoder, coder=org.glassfish.tyrus.core.coder.InputStreamDecoder@594be9d5, type=class java.io.InputStream}]}} dec 01, 2015 3:35:15 EM org.glassfish.tyrus.container.grizzly.client.GrizzlyWriter$WriterCondition$1 onError WARNING: Connection closed java.io.IOException: Connection closed at org.glassfish.grizzly.asyncqueue.TaskQueue.onClose(TaskQueue.java:317) at org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter.onClose(AbstractNIOAsyncQueueWriter.java:501) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.closeConnection(TCPNIOTransport.java:412) at org.glassfish.grizzly.nio.NIOConnection.doClose(NIOConnection.java:604) at org.glassfish.grizzly.nio.NIOConnection$5.run(NIOConnection.java:570) at org.glassfish.grizzly.nio.DefaultSelectorHandler.execute(DefaultSelectorHandler.java:234) at org.glassfish.grizzly.nio.NIOConnection.terminate0(NIOConnection.java:564) at org.glassfish.grizzly.nio.transport.TCPNIOConnection.terminate0(TCPNIOConnection.java:291) at org.glassfish.grizzly.nio.transport.TCPNIOAsyncQueueWriter.write0(TCPNIOAsyncQueueWriter.java:136) at org.glassfish.grizzly.nio.transport.TCPNIOAsyncQueueWriter.write0(TCPNIOAsyncQueueWriter.java:106) at org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter.processAsync(AbstractNIOAsyncQueueWriter.java:344) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:107) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.executeIoEvent(WorkerThreadIOStrategy.java:103) at org.glassfish.grizzly.strategies.AbstractIOStrategy.executeIoEvent(AbstractIOStrategy.java:89) at org.glassfish.grizzly.nio.SelectorRunner.iterateKeyEvents(SelectorRunner.java:414) at org.glassfish.grizzly.nio.SelectorRunner.iterateKeys(SelectorRunner.java:383) at org.glassfish.grizzly.nio.SelectorRunner.doSelect(SelectorRunner.java:347) at org.glassfish.grizzly.nio.SelectorRunner.run(SelectorRunner.java:278) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.IOException: An existing connection was forcibly closed by the remote host at sun.nio.ch.SocketDispatcher.write0(Native Method) at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51) at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) at sun.nio.ch.IOUtil.write(IOUtil.java:51) at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) at org.glassfish.grizzly.nio.transport.TCPNIOUtils.flushByteBuffer(TCPNIOUtils.java:149) at org.glassfish.grizzly.nio.transport.TCPNIOUtils.writeSimpleBuffer(TCPNIOUtils.java:133) at org.glassfish.grizzly.nio.transport.TCPNIOAsyncQueueWriter.write0(TCPNIOAsyncQueueWriter.java:126) ... 16 more{code} {code}2015-12-01 15:35:34,348 [Grizzly-worker(8)] FATAL com.volvo.adt.websocketserver.WebsocketEndPointImage.onError() - OnError: TyrusSession{uri=/websocket/images, id='e9251ffa-8de2-4069-9db5-5b1797871146', endpointWrapper=TyrusEndpointWrapper{endpointClass=null, endpoint=org.glassfish.tyrus.core.AnnotatedEndpoint@764e76ff, contextPath='/websocket', endpointPath=/websocket/images, encoders=[CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.NoOpTextCoder, coder=org.glassfish.tyrus.core.coder.NoOpTextCoder@4225658e, type=class java.lang.String}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.NoOpByteBufferCoder, coder=org.glassfish.tyrus.core.coder.NoOpByteBufferCoder@27109b6f, type=class java.nio.ByteBuffer}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.NoOpByteArrayCoder, coder=org.glassfish.tyrus.core.coder.NoOpByteArrayCoder@66854a9f, type=class [B}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.ToStringEncoder, coder=org.glassfish.tyrus.core.coder.ToStringEncoder@63f9213e, type=class java.lang.Object}], decoders=[CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$BooleanDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$BooleanDecoder@a1931da, type=class java.lang.Boolean}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$ByteDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$ByteDecoder@29f10815, type=class java.lang.Byte}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$CharacterDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$CharacterDecoder@65ec7e06, type=class java.lang.Character}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$DoubleDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$DoubleDecoder@4fb65354, type=class java.lang.Double}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$FloatDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$FloatDecoder@c623c99, type=class java.lang.Float}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$IntegerDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$IntegerDecoder@2df23ca0, type=class java.lang.Integer}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$LongDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$LongDecoder@2be87b56, type=class java.lang.Long}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.PrimitiveDecoders$ShortDecoder, coder=org.glassfish.tyrus.core.coder.PrimitiveDecoders$ShortDecoder@56b9b18c, type=class java.lang.Short}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.NoOpTextCoder, coder=org.glassfish.tyrus.core.coder.NoOpTextCoder@4ba2d936, type=class java.lang.String}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.NoOpByteBufferCoder, coder=org.glassfish.tyrus.core.coder.NoOpByteBufferCoder@7789fbde, type=class java.nio.ByteBuffer}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.NoOpByteArrayCoder, coder=org.glassfish.tyrus.core.coder.NoOpByteArrayCoder@1f530cb2, type=class [B}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.ReaderDecoder, coder=org.glassfish.tyrus.core.coder.ReaderDecoder@47dfb05, type=class java.io.Reader}, CoderWrapper{coderClass=class org.glassfish.tyrus.core.coder.InputStreamDecoder, coder=org.glassfish.tyrus.core.coder.InputStreamDecoder@594be9d5, type=class java.io.InputStream}]}} java.lang.IllegalStateException: The connection has been closed. at org.glassfish.tyrus.core.TyrusSession.checkConnectionState(TyrusSession.java:530) at org.glassfish.tyrus.core.TyrusSession.setState(TyrusSession.java:690) at org.glassfish.tyrus.core.TyrusEndpointWrapper.onPartialMessage(TyrusEndpointWrapper.java:1073) at org.glassfish.tyrus.core.TyrusWebSocket.onFragment(TyrusWebSocket.java:171) at org.glassfish.tyrus.core.frame.BinaryFrame.respond(BinaryFrame.java:91) at org.glassfish.tyrus.core.ProtocolHandler.process(ProtocolHandler.java:807) at org.glassfish.tyrus.core.TyrusWebSocketEngine$TyrusReadHandler.handle(TyrusWebSocketEngine.java:562) at org.glassfish.tyrus.container.grizzly.server.GrizzlyServerFilter$ProcessTask.execute(GrizzlyServerFilter.java:379) at org.glassfish.tyrus.container.grizzly.client.TaskProcessor.processTask(TaskProcessor.java:114) at org.glassfish.tyrus.container.grizzly.client.TaskProcessor.processTask(TaskProcessor.java:91) at org.glassfish.tyrus.container.grizzly.server.GrizzlyServerFilter.handleRead(GrizzlyServerFilter.java:215) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) at java.lang.Thread.run(Thread.java:745){code}

    Java.net JIRA | 1 year ago | rundgrent
    java.io.IOException: Connection closed
  2. 0

    dryRun = true - Results in strange errors

    GitHub | 7 months ago | jerrywiltse
    org.gradle.messaging.remote.internal.MessageIOException: Could not write message Failure[value=org.gradle.launcher.daemon.server.api.DaemonStoppedException: Gradle build daemon has been stopped.] to '/127.0.0.1:45101'.
  3. 0

    GitHub comment 1217#230831383

    GitHub | 5 months ago | gibsong
    org.gradle.internal.remote.internal.MessageIOException: Could not write '/127.0.0.1:50023'.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    ErrorPageFilter causes exception.

    GitHub | 2 years ago | landrade
    java.lang.RuntimeException: ClientAbortException: java.io.IOException: An existing connection was forcibly closed by the remote host

  1. MoYapro 7 times, last 2 weeks ago
  2. DoktorDoener666 5 times, last 3 weeks ago
  3. tvrmsmith 1 times, last 1 month ago
  4. dafman 1 times, last 2 months ago
  5. davidvanlaatum 2 times, last 2 months ago
21 more registered users
74 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.io.IOException

    An existing connection was forcibly closed by the remote host

    at sun.nio.ch.SocketDispatcher.write0()
  2. Java RT
    SocketChannelImpl.write
    1. sun.nio.ch.SocketDispatcher.write0(Native Method)
    2. sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51)
    3. sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
    4. sun.nio.ch.IOUtil.write(IOUtil.java:51)
    5. sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)
    5 frames
  3. Grizzly
    TCPNIOAsyncQueueWriter.write0
    1. org.glassfish.grizzly.nio.transport.TCPNIOUtils.flushByteBuffer(TCPNIOUtils.java:149)
    2. org.glassfish.grizzly.nio.transport.TCPNIOUtils.writeSimpleBuffer(TCPNIOUtils.java:133)
    3. org.glassfish.grizzly.nio.transport.TCPNIOAsyncQueueWriter.write0(TCPNIOAsyncQueueWriter.java:126)
    3 frames