FTP connection "hangs" on "LIST" - java

All,
I have an issue with a remote ftp server that has kept me busy for three days now and I am going nuts over it. :(
A while ago, I wrote a simple ftp retriever class that uses apache commons-net 2.0. The class works fine on 5 different ftp servers, I can retrieve data as I want.
Now I have come across a server that I need to connect to that just won't let me list directories or retrieve data.
This is the order of commands that are being sent and retrieved by my class:
220 (vsFTPd 2.0.1)
USER XXXXXXX
331 Please specify the password.
PASS XXXXXXX
230 Login successful
TYPE I
200 Switching to Binary mode.
PASV
227 Entering Passive Mode (XXX,XXX,XXX,XXX,XXX,XXX)
NLST
150 Here comes the directory listing.
226 Directory send OK.
SYST
215 UNIX Type: L8
PASV
227 Entering Passive Mode (XXX,XXX,XXX,XXX,XXX,XXX)
LIST
150 Here comes the directory listing.
At the last line, my code hangs indefinitely (well, I killed it after 2 hours of waiting to see how long it would block). I have tried everything, from using an active connection to setting ASCII type to using different ftp libraries - always with the same result.
Normally, I would just call the guys and tell them that their server is configured incorrectly. However, connecting via FileZilla not only works but is lightning fast and never causes any problems. Also, connecting via command line on linux works like a charm.
I am totally lost here. Does anybody have any ideas why I have this problem?
Cheers

I cannot believe that I spent almost five days on this. After long sessions of rolling back changes, committing intermediate versions, debugging and about 15923 cups of coffee, I finally found the reason for all this mess.
It turns out that - for whatever reason - as soon as you package xpp3 drivers (as in XStream) in your ear and deploy this on JBoss 5.1, any connection via any ftp libraries will get messed up.
I have no idea if this is caused by other libraries interfering with xpp3 or if it is xpp3 itself. Frankly, I could not care less, either at the moment. All I know is that as soon as I removed that dependency from my project everything worked like a charm.
Damn you, xpp3 - I will sue you for the ten years of my life you cost me! :)
Thanks all for your help, I am going home now...

Suggestion: install Wireshark on the client machine and capture network traces under both working (filezilla) and non-working conditions to see what's different. If you're on Linux use the tcpdump command to capture the packets and then use Wireshark to examine them.

Related

Impossible to bypass a session timeout in my company

I am coming to you to see if someone get my issue.
Let me explain the context:
We have a back side coded in Kotlin/Vertx and a front Side in Angular 8.
We upload and download some files on the datalake storage from Azure Cloud.
How we do that? An explorer is implemented in the front side and when we want to download a file, a request is sent to the back side and once it is finished we send a response success/error from back side to the front side.
Everything works well in local environement on upload or Download.
One particularity, In download side we can download ONE or SEVERAL files And when it is 2 or more files we compress them on back side before returning the response to the front side and download the 7zip file.
And as I said above, everything works well in our local environment.
But I am working on a big company and there some security as 4 minutes session TimesOut.
So when we have to download a file with a big size on my company environment even if it takes more than 4 minutes, it works because it hapenning something during the download (some packet are downloading).
But when we have to compress Big files, the time that the backside is zipping files (more than 4 minutes) the session cut (some firewall or something )
I tried to add a keep alive in front side or back side it doesn't worked.
I also tried every http code I found on the web but it its happening nothing.
Do you know how I can keep this session open by some function in Vertx?
Because, every thing I tried from vertx documentation or stackoverflow failed.
Thanks a lot for reading me,
Regards

Kerberos auth with java times out on external network

I followed this article to create a java program for testing kerberos authentication: https://docs.oracle.com/javase/jndi/tutorial/ldap/security/gssapi.html
The only thing I changed were the configuration files.
The program works fine when I point the DNS settings of my windows client to my internal windows DNS/Kerb server but it times out when I use a separate public DNS server, even though:
1. My internal server has ports tcp/udp 88 open
2. My external server has the SRV records needed (_kerberos._tcp and _kerberos._udp on port 88)
3. I'm able to achieve kerberos authentication, with and without a user certificate, using my iPad which is not using my windows server's DNS
Both the iPad and my other clients are using the same network (my home wifi) and I've also tried by sharing out the data connection from my cell phone.
Given #3 above and the fact that the java program works from a client that uses my internal DNS, I'm a bit baffled as to why my java program wouldn't work in both scenarios (i.e. using the internal or external DNS server).
Do you have any suggestions?
From GitBook Hadoop and Kerberos: The Madness Beyond the Gate section Error Messages to Fear
Switching Kerberos to use TCP rather than UDP makes [some bizarre
issues] go away ... Note also UDP is a lot slower to time out ...
Kerberos waits ~90 seconds before timing out, which is a long time to
notice there's a problem ...
In /etc/krb5.conf
[libdefaults]
udp_preference_limit = 1
PS: the "~90 seconds before timing out" may refer specifically to the Java-specific defaults i.e.
kdc_timeout = 30000
max_retries = 3
Generally speaking, UDP seems to be a root cause for many weird Kerberos issues, cf. How to save Kerberos Service Ticket using a Windows Java client? for instance.
Disabling it systematically might be a "good practise".

Trouble connecting to remote mysql (phpmyadmin) server from java (intellij)

I'm working on a project and I have a java program that parses a bunch of files and breaks them into records which are to be stored within a database. I've tested the program on my own server using the following (intellij generated) string:
And the above string works fine in the code and all the data is stored
But when I try to connect to the (external) project database located at 104.131.96.199 using the following
(There are two open ports: 22 and 80)
On port 80 it hangs on "connecting to database" forever (over 10 mins),
and on port 22 I get the packet size error above.
I've gone into phpmyadmin and changed the max_allowed_packet variable to 4739923, but still get the same issue (the change still isn't reflected in the error).
I'm not in charge of this db, although I have the admin user and pass.
Any help in the matter would be greatly appreciated
I guess I have 2 questions:
Is my connection string syntactically correct (and if not what should it be)
If the string is correct, what to do about the packet size issue / hanging forever
1.) Yes, the URL is syntactically correct. If you want to specify a user and password, you can add ?user=<username>&password=<password> to the end of the String.
2.) It most likely doesnt work because you are apparently using the SSH port (22) and the HTTP port (80) instead of the MySQL port (3306). If these are the only two open ports you will have to ask the server admin to manually allow remote connections to his MySQL server
Syntax is correct.
packet size issue - The changes to max_allowed_packet have possibly not taken effect. Run the below to check the value:
SHOW VARIABLES LIKE 'max_allowed_packet';
hanging forever - Check that the port used is correct.

FTP.changeWorkingDirectory not working when tried to FTP from Server

I am using FTP to transfer files from India to Germany.
When I try to transfer the files from my PC, everything works fine.
But, when I deploy the application in the Linux server in India and try to transfer,
the code ftp.changeWorkingDirectory("/") gives 'false' result.
However, I can do this transfer to another FTP setup in India.
The Server in Germany seems to have all the rights required when I check using FTPClient.
What may be the reason? What can I do to solve this problem?
You probably just do not have any permissions to visit the directory / (root). Try the same with a directory you definitely have access to.
If it works locally but not remotely, usually the problem is that you are not using PASSIVE mode in a situation where the server cannot connect back to you.
But here you already get an error when doing changeWorkingDirectory. Can you do ftp.cwd("/") (which returns an int, the FTP reply code) and show which error code you get?
Sorry..
It was was escape sequence error..
As it is different in Windows and Linux Systems.
Thanks for the help

Atmosphere framework examples do not work. Any idea?

Perhaps I am going mad, but I've spent the whole day just trying to get the standard samples on the atomosphere (https://github.com/Atmosphere/atmosphere-samples/) to work. Specifically the 'chat'. The instructions are simple - I follow them:
mvn package
cd samples/chat
mvn jetty:run
I visit localhost:8080 and I see the default page - it tells me it connects to the websockets. I see on the Jetty logs it registers the connection. I enter the 'user name' as requested, and then I get a javascript error 'WebSocket not connected.' - after a couple of minutes it says "Connection lost, trying to reconnect. Trying to reconnect 5000" upon which it then connects and works without any issues. Its the same on Chrome, firefox and Safari. Its also the same on 2 different Macs (mavericks) and 1 Windows 7 PC. It consistently fails like this. I have no firewall, proxy , etc running.
I am going out of my mind, and I cannot proceed with my work/project. Its getting late here and I'm dreading another whole day at this getting no where. Any ideas or can some just test this to make sure I'm not going mad? I posted on the user group but just got 'its your environment'. I've tried 3 environments and it makes no difference.
thanks
Ok. I think this 'Fix' has broken the samples;
https://github.com/Atmosphere/atmosphere-javascript/issues/74
debugging the atmosphere.js I see that webSocketOpened = true; is never set, and hence why the client can't send any messages as it thinks the connection is not open even though it is.
If I used client 2.1.4-SNAPSHOT the samples work fine.

Categories

Resources