Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Software caused connection abort: socket write error

 
coder watson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have TCP/IP based service which is continously 24*7 running on a port.
It communicates using XML.
when response is < 1023 characters...the client recieves data properly....
but when response is > 1023 characters the client recieves half the response (i.e exactly 1023 chars) and remaining chars are lost...and at the service end it throws exception:
Software caused connection abort: socket write error

Complete stack trace:
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)

at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:395)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191)
at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:111)
at java.io.BufferedWriter.write(BufferedWriter.java:212)
at java.io.Writer.write(Writer.java:126)
at com.icici.cardvalidator.queryserver.TCPXMLThread.run(TCPXMLThread.jav
a:328)
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)

at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:395)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191)
at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:111)
at java.io.BufferedWriter.write(BufferedWriter.java:212)
at java.io.Writer.write(Writer.java:126)
at com.icici.cardvalidator.queryserver.TCPXMLThread.run(TCPXMLThread.jav
a:328)
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"coder xyz " please check your private messages for an important administrative matter.
 
coder watson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my mistake....have updated the name ....
but can nybody help with the prob...
 
Vijay Jeyam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you reading the connection till you get the end of stream. Or you use a byte[] to read the 1024 char and closr the connection.

while (stream.read(byte[]) != -1) is there any place you have somethig like this
 
coder watson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THis is code i have written in client to read from the inputstream of the server.

************************************************

InputStream toServerinput = socket.getInputStream();
int i;
while ((i = toServerinput.read()) != -1)
{
inps.append((char) i);
if (toServerinput.available() == 0)
{
break;
}
}
****************************************************
 
Vijay Jeyam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code will be something like this which is to read the iStream completely.

// Some input stream where you read data iStream

byte[] b = new byte[1024];
while(iStream.read(b) != -1){
/// Do something
}
 
coder watson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
still m able to get only half the packet......thats....8192 chars...
but in response there are 62000 chars.....
i set byte array..
byte b = new byte[64000]...
but only getting...8000 chars or so...
need help.....to read full response...
 
Ben Spink
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
coder watson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic