Interesting Problem - Host or Server instantly closing connection
I have a rather interesting problem. I'm looking more for guesses at what is happening, than a solution.
Here is a quick overview for reference:
So I have an applet embedded on a website. The runtime data comes from files on the same server (which is a free host) as the website. I have one section of code which reads a server directory and parses for a list of files in the directory. To connect to the directory, I am using URLConnection and a BufferedReader (which I send a InputStreamReader to), and I connect via FTP (instead of usual URL) due to server related restrictions. I then have other sections of code that uses the same basic principle to read files (instead of a directory listing).
Now, my problem is ONLY with the directory listing part. The rest of the file reading works perfectly (as far as I know). Here is where it gets interesting: my problem seems to be specific to only certain machines. I've attempted to run the program on 3 separate machines, 2 of which worked, and the other one failed, throwing a java.net.SocketException: Connection Reset. I've attempted to pinpoint the problem, but the more variables I take into account, the further I seem get from the answer. Here are my test cases:
Computer 1: Windows 7, Firefox 3.6, Network A, Virus Protection A
Computer 2: Windows 7, Firefox 12 (no addons), Internet Explorer 9 (no addons), Network A, Virus Protection A
Computer 3: Windows 7, Firefox 12 (no addons), Internet Explorer 9 (no addons), Network B, Virus Protection B
Now, Computer 1 and 3 work perfectly. Computer 1 and Computer 2 are on the same network (while Computer 3 is in an entirely different county), so I've ruled out the network. Computer 2 fails on all of its browsers (Firefox, Chrome, and Internet Explorer). However I've ruled out browser conflicts due to Computer 3. All 3 computers run the same operating system, so I've ruled that out. And Computer 1 and Computer 2 have the same Virus Protection program, so I can rule that out. It is clearly something specific to Computer 2, but I have no clue what it could be.
I've pretty much ran out of variables here. Does anyone have any ideas for why one computer would throw a SocketException, while others wouldn't? Or can anyone think of any more variables I can rule out?
Re: Interesting Problem - Host or Server instantly closing connection
While I can only guess at what's wrong, I will point out an alternative - presuming computer 2 is capable of reading a webpage URL. Write a dynamic webpage which acts as an intermediary that prints out the files and directory. I say this for 2 reasons: 1) unless you've truly obfuscated the code of your applet, someone with bad intentions could de-compile the applet, which gives them access access to your ftp user/pass allowing them to do whatever they wish on the server. Doing it through an intermediate webpage would be more secure/ 2) It would remove the need for FTP access, which could be the foundation of your problem.
Re: Interesting Problem - Host or Server instantly closing connection
The problem I can foresee with that method is that the User reads and writes to the files on the server, so FTP is important for making the changes to the files.
I am printing out the directory listing because I am unsure how many files will be in the directory, and what their names will be, at runtime. I have thought about having an intermediate file that simply has a list of the files in the directory, but that would leave open the possibility of a user corrupting that file (perhaps through users overwriting one another) and preventing all the rest of the users from finding their files.
Also, how would a dynamic webpage react when many users request data all at once? It is very common for the program to parse a data file to look for a specific line, as some of these data files are over 2 gigs in size and doing a full read of the entire file would take way too long.
Re: Interesting Problem - Host or Server instantly closing connection
Quote:
Originally Posted by
aussiemcgr
The problem I can foresee with that method is that the User reads and writes to the files on the server, so FTP is important for making the changes to the files.
I am printing out the directory listing because I am unsure how many files will be in the directory, and what their names will be, at runtime. I have thought about having an intermediate file that simply has a list of the files in the directory, but that would leave open the possibility of a user corrupting that file (perhaps through users overwriting one another) and preventing all the rest of the users from finding their files.
Also, how would a dynamic webpage react when many users request data all at once? It is very common for the program to parse a data file to look for a specific line, as some of these data files are over 2 gigs in size and doing a full read of the entire file would take way too long.
I'd worry more about FTP than see it as an advantage (for the same reason above). Just my .02 though. Everything you need can be done by wrapping the OS with some dynamic pages, or better yet writing an application server...its daunting and can be a lot of work, and depending upon your server might require using a language other than java. All this being said my posts didn't address your original question, but hopefully gave some insight into an alternative that you can choose to follow if you wish.