Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Socket error Windows getInputStream

Reply
Thread Tools

Socket error Windows getInputStream

 
 
vicky7909@rediffmail.com
Guest
Posts: n/a
 
      03-18-2008
Hello,

Java version is 1.5.0_09. I am trying to connect from a Windows
machine to another Windows machine using sockets . Getting a socket
error for the following line. and throws EOFException

Socket s = null;
ObjectInputStream sin = null;
ObjectOutputStream sout = null;

s = new Socket( host, port );
sout = new ObjectOutputStream( s.getOutputStream() );

//write data to socket
sout.writeObject( req );
sout.flush();

InputStream is = s.getInputStream() );
sin = new ObjectInputStream( is ); // This line gives error

If I step into ObjectInputStream, I see:

public ObjectInputStream(InputStream in) throws IOException {
verifySubclass();
bin = new BlockDataInputStream(in);
handles = new HandleTable(10);
vlist = new ValidationList();
enableOverride = false;
readStreamHeader(); // This line gives error
bin.setBlockDataMode(true);
}


However, the same code works when I try to connect from Linux(Red Hat
Enterprise Linux WS release 4 (Nahant Update 5)) to Windows. Turned
off Windows firewall but no luck.

On the Windows Server I am trying to connect to a server agent waiting
on port 2002 that helps me connect to Citrix running on that machine.
The agent runs as a Windows service.

What could be wrong here?

Stack Trace

java.io.EOFException
at java.io.ObjectInputStream
$PeekInputStream.readFully(ObjectInputStream.java: 222
at java.io.ObjectInputStream
$BlockDataInputStream.readShort(ObjectInputStream. java:2694)
at java.io.ObjectInputStream.readStreamHeader(ObjectI nputStream.java:
761)
at java.io.ObjectInputStream.<init>(ObjectInputStream .java:277)
....
at
org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:
202)
at
org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:
173)
at
org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:
213)
at
org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:
17
at
org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:
126)
at
org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:
105)
at
org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:
107)
at
org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:
14
at
org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:
869)
at org.apache.coyote.http11.Http11BaseProtocol
$Http11ConnectionHandler.processConnection(Http11B aseProtocol.java:
664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:
527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:
80)
at org.apache.tomcat.util.threads.ThreadPool
$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
 
Reply With Quote
 
 
 
 
Knute Johnson
Guest
Posts: n/a
 
      03-18-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hello,
>
> Java version is 1.5.0_09. I am trying to connect from a Windows
> machine to another Windows machine using sockets . Getting a socket
> error for the following line. and throws EOFException
>
> Socket s = null;
> ObjectInputStream sin = null;
> ObjectOutputStream sout = null;
>
> s = new Socket( host, port );
> sout = new ObjectOutputStream( s.getOutputStream() );
>
> //write data to socket
> sout.writeObject( req );
> sout.flush();
>
> InputStream is = s.getInputStream() );
> sin = new ObjectInputStream( is ); // This line gives error
>
> If I step into ObjectInputStream, I see:
>
> public ObjectInputStream(InputStream in) throws IOException {
> verifySubclass();
> bin = new BlockDataInputStream(in);
> handles = new HandleTable(10);
> vlist = new ValidationList();
> enableOverride = false;
> readStreamHeader(); // This line gives error
> bin.setBlockDataMode(true);
> }
>
>
> However, the same code works when I try to connect from Linux(Red Hat
> Enterprise Linux WS release 4 (Nahant Update 5)) to Windows. Turned
> off Windows firewall but no luck.
>
> On the Windows Server I am trying to connect to a server agent waiting
> on port 2002 that helps me connect to Citrix running on that machine.
> The agent runs as a Windows service.
>
> What could be wrong here?
>
> Stack Trace
>
> java.io.EOFException
> at java.io.ObjectInputStream
> $PeekInputStream.readFully(ObjectInputStream.java: 222
> at java.io.ObjectInputStream
> $BlockDataInputStream.readShort(ObjectInputStream. java:2694)
> at java.io.ObjectInputStream.readStreamHeader(ObjectI nputStream.java:
> 761)
> at java.io.ObjectInputStream.<init>(ObjectInputStream .java:277)
> ...
> at
> org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:
> 202)
> at
> org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:
> 173)
> at
> org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:
> 213)
> at
> org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:
> 17
> at
> org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:
> 126)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:
> 105)
> at
> org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:
> 107)
> at
> org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:
> 14
> at
> org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:
> 869)
> at org.apache.coyote.http11.Http11BaseProtocol
> $Http11ConnectionHandler.processConnection(Http11B aseProtocol.java:
> 664)
> at
> org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:
> 527)
> at
> org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:
> 80)
> at org.apache.tomcat.util.threads.ThreadPool
> $ControlRunnable.run(ThreadPool.java:684)
> at java.lang.Thread.run(Thread.java:595)


I'm not sure what your problem is. I've done this quite a few times
between Windows machines with no problem. If the communications is
two-way it is usually necessary to create the ObjectOutputStream before
the ObjectInputStream. That can cause some problems but it is usually
hangs and not EOFExceptions.

Probably the simplest thing you can do here is write a couple of test
programs and see if you can see where the problem is actually happening.
Sometimes removing all the other code gets you to the problem in the
original code.

--

Knute Johnson
email s/nospam/linux/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDem
 
Reply With Quote
 
 
 
 
EJP
Guest
Posts: n/a
 
      03-18-2008
(E-Mail Removed) wrote:
> java.io.EOFException


That means the other end has already closed the connection, or possibly
an intermediate router has timed out.
 
Reply With Quote
 
vicky7909@rediffmail.com
Guest
Posts: n/a
 
      03-19-2008
On Mar 18, 6:31 pm, EJP <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > java.io.EOFException

>
> That means the other end has already closed the connection, or possibly
> an intermediate router has timed out.


So how do I get around this? I was able to connect until day before
and suddenly I started getting this error.

Thanks for posting your answer in both forums
 
Reply With Quote
 
vicky7909@rediffmail.com
Guest
Posts: n/a
 
      03-19-2008
On Mar 19, 11:21 am, (E-Mail Removed) wrote:
> On Mar 18, 6:31 pm, EJP <(E-Mail Removed)> wrote:
>
> > (E-Mail Removed) wrote:
> > > java.io.EOFException

>
> > That means the other end has already closed the connection, or possibly
> > an intermediate router has timed out.

>
> So how do I get around this? I was able to connect until day before
> and suddenly I started getting this error.
>
> Thanks for posting your answer in both forums



It worked after rebooting Windows a couple of times. I made no code
change.
 
Reply With Quote
 
Knute Johnson
Guest
Posts: n/a
 
      03-19-2008
(E-Mail Removed) wrote:
> On Mar 19, 11:21 am, (E-Mail Removed) wrote:
>> On Mar 18, 6:31 pm, EJP <(E-Mail Removed)> wrote:
>>
>>> (E-Mail Removed) wrote:
>>>> java.io.EOFException
>>> That means the other end has already closed the connection, or possibly
>>> an intermediate router has timed out.

>> So how do I get around this? I was able to connect until day before
>> and suddenly I started getting this error.
>>
>> Thanks for posting your answer in both forums

>
>
> It worked after rebooting Windows a couple of times. I made no code
> change.


Ah Windows. Always something new.

--

Knute Johnson
email s/nospam/linux/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDem
 
Reply With Quote
 
vicky7909@rediffmail.com
Guest
Posts: n/a
 
      03-20-2008
On Mar 19, 5:11 pm, Knute Johnson <(E-Mail Removed)>
wrote:
> (E-Mail Removed) wrote:
> > On Mar 19, 11:21 am, (E-Mail Removed) wrote:
> >> On Mar 18, 6:31 pm, EJP <(E-Mail Removed)> wrote:

>
> >>> (E-Mail Removed) wrote:
> >>>> java.io.EOFException
> >>> That means the other end has already closed the connection, or possibly
> >>> an intermediate router has timed out.
> >> So how do I get around this? I was able to connect until day before
> >> and suddenly I started getting this error.

>
> >> Thanks for posting your answer in both forums

>
> > It worked after rebooting Windows a couple of times. I made no code
> > change.

>
> Ah Windows. Always something new.
>
> --
>
> Knute Johnson
> email s/nospam/linux/
>
> --
> Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
> ------->>>>>>http://www.NewsDem


I'm probably going to set-up an alternate dev. environment on Linux -
just in case. I lost half a day.
 
Reply With Quote
 
Knute Johnson
Guest
Posts: n/a
 
      03-20-2008
(E-Mail Removed) wrote:
> On Mar 19, 5:11 pm, Knute Johnson <(E-Mail Removed)>
> wrote:
>> (E-Mail Removed) wrote:
>>> On Mar 19, 11:21 am, (E-Mail Removed) wrote:
>>>> On Mar 18, 6:31 pm, EJP <(E-Mail Removed)> wrote:
>>>>> (E-Mail Removed) wrote:
>>>>>> java.io.EOFException
>>>>> That means the other end has already closed the connection, or possibly
>>>>> an intermediate router has timed out.
>>>> So how do I get around this? I was able to connect until day before
>>>> and suddenly I started getting this error.
>>>> Thanks for posting your answer in both forums
>>> It worked after rebooting Windows a couple of times. I made no code
>>> change.

>> Ah Windows. Always something new.
>>
>> --
>>
>> Knute Johnson
>> email s/nospam/linux/
>>
>> --
>> Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
>> ------->>>>>>http://www.NewsDem

>
> I'm probably going to set-up an alternate dev. environment on Linux -
> just in case. I lost half a day.


They both have problems and they are different. There are a lot of
posts here "My xyz works on Linux but not on XP" or vice versa.

I'm fighting one now where a server program running on a Windows machine
gets stopped by random blow ups of svchost.exe. It will run for weeks
without a problem and then stop two or three times in one day. It's
enough to drive you nuts.

--

Knute Johnson
email s/nospam/linux/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      03-20-2008
On Tue, 18 Mar 2008 14:47:15 -0700 (PDT), (E-Mail Removed)
wrote, quoted or indirectly quoted someone who said :

>java.io.EOFException


the other end closed the stream right away.

You might want to use a protocol sniffer to see what the other end is
up to.

see http://mindprod.com/jgloss/sniffer.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
EJP
Guest
Posts: n/a
 
      03-20-2008
Roedy Green wrote:
> You might want to use a protocol sniffer to see what the other end is
> up to.


The other end, or somebody, send a FIN. No sniffing required really.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 0 02-01-2009 07:37 AM
socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 1 01-27-2009 05:05 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48,'Address already in use') Jean-Paul Calderone Python 0 01-27-2009 01:41 PM
java.net.Socket.close() and getInputStream HK Java 3 03-11-2005 11:29 AM
how can i read from a socket.getinputstream?! mike Java 1 09-09-2004 09:13 AM



Advertisments