• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sending data by java socket throws error or keeps hanging.

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Marshal
Posts: 4491
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 4491
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 86
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 4491
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great - thanks for reporting back with the good news.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic