Need a help to perform operation ipv6 ftp server - java

I am using linux box.
I am unable do any operation using IPv6 FTP server.I am able to connect using IPV6 FTP server.
But when I will do any operation(like ls,get,put ..) it's giving below exception(Highlighted with bold).
[root#SKP-vlnx ~]# ftp aa01:9:1::22:56ff:231:4b
Connected to aa01:9:1::22:56ff:231:4b (aa01:9:1::22:56ff:231:4b ).
220 Service ready for new user
Name (aa01:9:1::22:56ff:231:4b ): xyz
331 User name okay, need password for ftp-user
Password:
230 User logged in, proceed
Remote system type is UNIX.
ftp> ls
502 Command EPSV not implemented
502 Command LPSV not implemented
Passive mode refused.
Any body please help on this.

This means, that the server either does not implement the necessary commands for IPv6 passive mode, which are different from the old IPv4 passive mode (new EPSV, old PASV). This might be either because the server is not really IPv6 ready or because it does not implement passive mode at all.
You might try to use active mode. But, if the server is not really IPv6 ready you will run into the same problem because this also requires a new command for IPv6 (EPRT instead of PORT).

Related

How to block java application from sending email during development?

My application sends some emails to our customers to warn them about some errors while we process their files. However, I would like to disable this feature, without altering my code, for development/test purposes.
Is there any argument to pass to my JVM in order to block it from sending emails ?
You can replace the JavaMail provider with one that "mocks" a real provider, just by adding a jar to your classpath. In addition to blocking outbound mail, it allows you to perform unit testing on your application's email functions. This library was created by Kohsuke Kawaguchi, creator of Hudson/Jenkins.
If the SMTP server's hostname is hardcoded in the code, for example:
server = "smtp.example.com"
You could alter the host file at /etc/hosts to override the DNS lookup. Add this to your hosts file:
127.0.0.1 smtp.example.com
This will prevent your program from interacting with the mail server. Make sure to delete that line when you are done.
Otherwise, if the IP address is what's hardcoded, you can use a firewall. The exact procedure will depend on the operating system you are using. If you're running an OS with a Linux kernel, you can use iptables to block that IP address:
iptables -I OUTPUT 1 --destination 1.2.3.4 -j REJECT
Or, for a more specific rule:
iptables -I OUTPUT 1 --destination 1.2.3.4 -p tcp --dport 25 -j REJECT --reject-with tcp-reset
Again, remember to change it back when you're done:
iptables -D OUTPUT 1

Connection to <hostname>:5432 refused

I'm not a pro in communication networks, so I have no idea what should be my "hostname" and where can I find it?
I created a postgreSQL server on ubuntu 14.04, I can connect to it from the same computer without problem by setting hostname to 127.0.0.1(localhost), or even 192.168.1.42 (my private ip). But I can not connect to my server from any other computer, even if they are on local network or not. I always get this message:
"Connection to <hostname>:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections."
where is either 127.0.1.1, 127.0.0.1, 192.168.1.42, 98.765.432.123(public ip) or anything else, it never works.
What is the right hostname?
I already set listen_addresses to '*', already edited pg_hba.conf to accept 0.0.0.0/0 IP-s, and disabled ubuntu firewall.
This could be caused by many things.
The server has an IP address. That is the address that the JDBC connection string should use for <hostname>, unless you have some local DNS solution. To rule out problems with the latter, use the IP address of the Ubuntu server. On Ubuntu type ifconfig to see it; it probably is 192.168.1.42 like you mentioned. So from the client with the Java app, you use the IP address of the server.
If you have a standard PostgreSQL installation, it should use port 5432, you can check the setting in postgresql.conf. In the JDBC connection string you should also indicate the port: "jdbc:postgresql://192.168.1.42:5432/...", just to be on the safe side.
You need to have a database that you can connect to. Note that by default only the owner of the database (probably the user postgres in your case) can connect to it. See further down.
In pg_hba.conf you need to create an entry for your new database so it can be connected to (typical settings, check your network setup). The IP address (range) you specify here is that of the clients connecting to the database!
host my_db all 192.168.0.0/16 md5
You must restart your PostgreSQL server after modifying pg_hba.conf. (Typically on Ubuntu, do sudo ./etc/init.d/postgresql restart)
To create database my_db (or whatever name you prefer), go to your Ubuntu box and enter psql as the postgres user:
vekszor#ubuntu:~$ sudo -u postgres psql
[sudo] password for user:
psql (9.3.5)
Type "help" for help
postgres=#
In order to connect to the database, you should have a database:
postgres=# CREATE DATABASE my_db;
CREATE DATABASE
You also want a user (role) that is less powerful than the postgres superuser, but still able to manipulate the database. So create this user role and assign ownership of the database:
postgres=# CREATE ROLE vekszor LOGIN PASSWORD 'secret123' CREATEROLE;
CREATE ROLE
postgres=# ALTER DATABASE my_db OWNER TO vekszor;
ALTER
Now you can go back to your client computer with the Java app and finish the JDBC connection string with the name of the database, the user and password.
Note that if you want to access your database from the internet, you should set up a NAT rule in your router to point traffic on port 5432 to the IP of your Ubuntu server.So long as the internal address of the router is in the same address range of the client computers that you indicated in pg_hba.conf this should be easy to set up, otherwise add a new entry in pg_hba.conf.
Reading your comments to the correct answer:
This is how you add a rule to iptables:
iptables -A INPUT -s 0/0 -p tcp --dport 5432 -j ACCEPT
0/0: If you want anybody to access it. You can change it to a specific ip address or range of ip addresses.
If you are connected to the server using UI you can run the below query to get the IP Address of server using below query to verify if you are using the correct IP.
Select inet_server_addr();

Not logged in error message while connecting to ftp server

I am using com.enterprisedt.net.ftp.FTPClient to login my FTPSERVER
using the following command ftpClient.login(USER_NAME,PASSWORD());
am using com.enterprisedt.net.ftp.
But some times am getting "Not logged in" error.
FTP server has a domain name. but i log in only with user name and pwd and host name as the dns name.
In some 10, 15 , 20 minutes I get a "not logged in" error.
It is not occuring always, not in any specific pattern also, but immedietly after the error the connection is succesful.
[INFO] [FTPPull : getFTPConnection] - Error occured while FTP login : Not logged in The host is xxx.yyy.in The port used is 6370 [12] [2011-11-10 14:59:18 CET ]
but next connection was succesful
[INFO] [FTPPull : getFTPConnection] - Login Successful [12] [2011-11-10 15:09:18 CET ]
Please help, not sure why sometimes getting connected and sometimes not connected.
Regards,
Sridevi
Your problem is probably that there is a timeout at the FTP command channel level. When your client detects it, it reconnects automatically, as you have witnessed.
Now, you have to understand where that timeout comes from: either the client side or the server side:
first check the configuration on the server side: can you change the command channel timeout to a higher value, or even to infinite?
then check the API for your client (I personally use Apache Commons' FTP client): does it have a way to set the timeout too?
finally, check in the API whether sockets to the command channel use TCP keepalive; if not, does it have a method to set it? If you pass a Socket yourself to the constructor, make it keepalive before constructing your client instance.
The most likely scenario is however that the FTP server itself closes the command channel. Changing that is implementation dependent.
A good way to check the server side disconnection is to use a command line FTP client to check. I personally use lftp for that:
$ lftp ftp://some.ftp.site/
lftp> debug
# idle, idle...
# if the server times out, it will tell you so

could not open connection to the host, on port 23: Connect failed

I have extremely simple chat server (100 lines of code on Java) and it is working properly. When I'm testing it with Telnet on localhost everything is just fine. When I asked some of my friends to test it with telnet (telnet <myIP> <port>, the port I assigned is 5555, server is running on my PC with static IP) everything is just fine too, but one of my friends received the error
Could not open connection to the host, on port 23: Connect failed
when he was trying to connect. Every firewall, anti-virus and anti-spyware software is turned off from both sides. Why could some of my friends connect but not him? Where is the problem: is it on the server or his PC?
I had a similar issue before and what it turns out to be is the syntax. When I do:
telnet 192.168.10.10:3333
I will get the port 23 error but if I type in:
telnet 192.168.10.10 3333
I will get correct result.
Try to make the telnet connection as
telnet 192.168.10.10 3333
without using :
Your friend's Telnet client is obviously attempting to connect to port 23, not 5555 or 43839, since that's what it says in the error message he is getting.
Ask your friend to check the documentation for the Telnet client he's using, and make sure he's specifying the port the proper way.

How to determine what server is listening on Port 80

I need to determine, what web server (IIS, Apache, Jetty) is running on port 80 in Java.
Are there any solutions to get the informations via port 80?
Thanx and reguards
Stefan
You can ask it - issue a HEAD request, e.g. open a TCP connection on port 80 and just send
HEAD / HTTP/1.0
or
HEAD / HTTP/1.1
Host: the.server.hostname.com
and the reply should contain a Server line
Server: Microsoft-IIS/5.1
amongst other things.
If you want to ask the OS which process, though, I don't know a Java-portable way. Command line you would run netstat -ano or (-anp on linux I think) which will give you the process number listening on port 80, and then you can look that up to find out exactly which server has the port.
Look at the Server: HTTP header. It will usually contain something like this:
Server: Apache/2.2.10 (SpaceNet) PHP/5.2.6
Of course, the server can send whatever it likes, or not send anything at all.

Categories

Resources