• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending data by java socket throws error or keeps hanging.  RSS feed

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to send a postscript file to printer through java batch.
Below is the code im using. If the file is small (for example 200 KB), it immediately throws exception .



If the file size is large (Example 15 MB), program hangs at the below statement and it stays there forever.



I am not sure whether the problem is with my data file or any network error.

Please throw some light on this.


 
Saloon Keeper
Posts: 1826
238
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran your code using Netcat to simulate the printer side and it completed (15MB) with no errors.  However if I closed the Netcat part-way through the transfer, I get the same exception that you reported:You can use a packet sniffer like Wireshark or tcpdump view the network traffic and help determined what happened.  In my case, you can see that the printer-side (172.25.160.22) closed the connection (TCP FIN):
 
murali jackson
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ron,

Thanks very much for your explanation !!!
I will use TCPDUMP to check the reason behind the exception. Might be the printer is rejecting the file. I will share my findings shortly. Thanks again...
 
murali jackson
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have installed wire shark in my system.
Please guide me on how to use this tool to monitor the traffic at my printer . I have googled but did not find what i was looking for. Please advise. Thanks !!!
 
Ron McLeod
Saloon Keeper
Posts: 1826
238
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it would be best to refer to the Wireshark User Guide for the details of how to use the tool, however to get started, use a capture filter specifying the port number you will use to communicate with the printer, and then select the interface to monitor (you may only have one).



If you need help interpreting what Wireshark is telling you, post back here.
 
murali jackson
Ranch Hand
Posts: 74
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ron,

Thanks very much for your help !!!
I have used the tool and found the problem.

I was sending post script file to the printer but the printer expects job name in the first line of the postscript. It was missing in the file. So it initially accepts the connection but later resets because of the jobname missing.
I have added the job name and it went through fine.

Thanks for helping me out on this
 
Ron McLeod
Saloon Keeper
Posts: 1826
238
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great - thanks for reporting back with the good news.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!