I installed the WordnetSimilarity server on my Ubuntu.
I launch it with the command:
$ similarity_server.pl --logfile server.log
Now I want to use it from my Java/Groovy app, and I wrote this code to get the server version:
// open connection
Socket kkSocket = new Socket("localhost", 31134);
def out = new PrintWriter(kkSocket.getOutputStream(), true);
def inbuf = new BufferedReader(new InputStreamReader(kkSocket.getInputStream()));
out.write("v") // command for the server
out.write("\015\012") // end of message
out.flush()
// so far so good
println inbuf.readLine()
// no response, hanging...
Nothing happens, and the server log is empty. The server protocol is defined in here: http://search.cpan.org/~tpederse/WordNet-Similarity-2.05/utils/similarity_server.pl
The server is definitely running, because if I stop it, the socket allocation fails.
Any hint?
Cheers, Mulone
It looks like it should work. I suspect that there is a problem with the server. Some things to try:
Are there any other clients you can use to see if the server is responding properly?
Is there any "verbose" output option for the server?
Is the server able to access whatever resources it needs, e.g., WordNet over an internet connection?
Can you debug the server process?
On the client, you can try reading one character at a time.
Related
I have developed a Java application that uses ArangoDB as backend database (Used ArangoDB Java-Driver/Interface to access ArangoDB).
Everything is good until my ArangoDB and Application resides on same machine.
Once i moved ArangoDB to remote machine(Dedicated Server), my application is unable to access it :(
I have given my remote machine details(ArangoDB Server) in some properties file and feeding that file location to ArangoConfigure Constructor while creating ArangoDriver Object. But still i'm unable to access ArangoDB :(
Small snippet of my code is below:
protected static ArangoConfigure getConfiguration() {
//ArangoConfigure configure = new ArangoConfigure();
ArangoConfigure configure = new
ArangoConfigure("/Volumes/Official/ZLabs/arangodb.properties");
configure.init();
return configure; }
protected static ArangoDriver getArangoDriver(ArangoConfigure
configuration) { return new ArangoDriver(configuration); }
Please help me in this regard.
Awaiting your response.
Thanks & Best Regards,
- Mahi
First of all thank you #dothebart for all your help.
#dothebart, I have checked all the details that you have mentioned, before i posted here. Only thing is missed is HTTP connectivity thanks for pointing that.
Actually the below code change has fixed the problem for me.
Earlier code:
ArangoConfigure configure = new ArangoConfigure("/home/arango.properties");
configure.init();
ArangoDriver driver = new ArangoDriver(configuration);
Modified Code:
ArangoConfigure configure = new ArangoConfigure("/home/arango.properties");
ArangoHost hostObj = new ArangoHost(<IP-Address>, 8529);
configure.setArangoHost(hostObj);
configure.setUser(<user-name>);
configure.setPassword(<password>);
configure.init();
ArangoDriver driver = new ArangoDriver(configuration);
Setting up of host, username and password again is making it to work :(
File has all the details, then why should i provide them again.. I didn't understand that.
#dothebart i'm unable to find the log file, please let me know where can i find it.
If the Aranngodb Java driver fails to open or parse /Volumes/Official/ZLabs/arangodb.properties it issues a log message.
If arangodb properties looks like that:
port=8529
host=192.168.22.17
user=root
password=OpenSesame
enableCURLLogger=false
You start walking up the OSI model to debug TCP connection problems to evade possible connection issues due to firewals, routing etc.
One uses the commonly available telnet command to test the availability of the server:
telnet 192.168.22.17 8529
Trying 192.168.22.17...
If it sits there forever, you most probably have a firewall filtering you away, you finaly will get:
telnet: Unable to connect to remote host: Connection timed out
If it immediately exits with:
telnet: Unable to connect to remote host: Connection refused
It seems the server doesn't answer.
On the server side you then can check whether the service has bound the port (8529) you're trying to connect:
netstat -alpnt |grep 8529
tcp 0 0 0.0.0.0:8529 0.0.0.0:* LISTEN 19912/arangod
If you instead see it binding 127.0.0.1:8529 you won't be able to connect it remotely and need to change arangod.conf like this:
[server]
endpoint = tcp://0.0.0.0:8529
And then restart ArangoDB. Then, you should be able to see something like this:
telnet 192.168.22.17 8529
Trying 192.168.22.17...
Connected to 192.168.22.17.
Escape character is '^]'. <start to type now: >
GET / HTTP/1.0
<server should reply:>
HTTP/1.1 301 Moved Permanently
Location: /_db/_system/_admin/aardvark/index.html
Content-Type: text/html
Server: ArangoDB
Connection: Close
Content-Length: 197
<html><head><title>Moved</title></head><body><h1>Moved</h1>
<p>This page has moved to /_db/_system/_admin/aardvark/index.html.
</p></body></html>Connection closed by foreign host.
This looks like the properties-file isn't found in the classpath.
The path of the log-file should be configured in your log-configuration-file in your project.
Your project may use for example Logback (logback.xml) or another slf4j implementation.
With my Java-Program I'm connecting to a FTP server with Apache Commons Net.
The FTP server works as the update server for my software and currently everytime I check for updates, the updater downloads a .txt and checks if the version number written in the file is greater than the version number currently installed on the machine.
Is there a way to get the version number of the update for the software on the machine from the welcome-message of the FTP server?
Then I don't have to download the .txt to check for updates instead I'm able to only connect to the server and check the welcome-message for the number?
The welcome message is effectively a "response" to a connection.
So after you connect using the FTPClient.connect(), use the FTPClient.getReplyStrings() to retrieve the welcome message.
ftp.connect(server);
// After connection attempt, you should check the reply code to verify success.
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
ftp.disconnect();
System.err.println("FTP server refused connection.");
System.exit(1);
}
// read the initial response (aka "Welcome message")
String[] welcomeMessage = ftp.getReplyStrings();
I am attempting to use the JSch class (Java Secure Channel; jsch-0.1.50.jar) to connect to an SFTP server and send a file from within a ColdFusion (9.0.2) application (which runs atop Java 1.7.0_15). The basic code in question is:
jsch = classLoader.create("com.jcraft.jsch.JSch").init(); // ColdFusion-specific to load the jar
jschSession = jsch.getSession("myusername", "ftp.example.com", 22);
jschSession.setConfig("StrictHostKeyChecking", "no");
jschSession.setTimeout(60000);
jschSession.setPassword("mypassword");
jschSession.connect();
Upon connection to a Serv-U SFTP server it is giving me the following error on the Serv-U side immediately after the connection opens:
SSH Protocol Error: packet size exceeds maximum allowed.
Serv-U then closes the session, at which point JSch throws the exception:
Session.connect: java.io.IOException: End of IO Stream Read
I am new to the JSch class, and it's possible I'm missing something obvious, but I am at a loss as to where the error may lie. Connecting to the same SFTP server from the same origin with WinSCP gives no errors. Any tips on what the code is doing wrong or where to turn next for troubleshooting?
SSH Protocol Error: packet size exceeds maximum allowed
This means that the local client received some data from the remote server which wasn't properly formatted as an SFTP protocol message. The usual reason is that the server sent some kind of plain text message through the SSH connection. There are few things that might be going on:
Your .bashrc, .bash_profile, or similar shell configuration file on the server is set to print some message.
The server is poorly configured, and it's sending some kind of greeting.
The server is sending some kind of error message.
If you have access to the ssh command-line utility, you can use that to see what the server is sending. Run something like this:
$ ssh myusername#ftp.example.com -s sftp
This will open a plain SSH session to the remote server and request the SFTP subsystem, which is the same thing an SFTP client would do. If the server starts SFTP properly, you won't see any output from this command--it'll just wait until you kill it. If you see any text from the remote server, that is the problem. You'll need to figure out why the server is sending that text and prevent it.
I am trying to use apache commons to send manual FTP commands as I have to send non-standard FTP commands to a specific server (that accepts them)
Before I try to send these non-standard commands I want to get FTP working manually with commons.net.ftp. Unfortunately I seem to be missing something.
This works fine (i.e. it retrieves the list of files)
FTPClient ftp = new FTPClient();
FTPClientConfig config = new FTPClientConfig();
ftp.configure(config);
ftp.connect("ftp.mozilla.org");
ftp.login("anonymous", "");
ftp.enterLocalPassiveMode();
FTPFile[] fileList = ftp.listFiles("/");
This doesn't
FTPClient ftp = new FTPClient();
FTPClientConfig config = new FTPClientConfig();
ftp.configure(config);
ftp.connect("ftp.mozilla.org");
ftp.login("anonymous", "");
ftp.sendCommand("PASV");
ftp.sendCommand("NLST");
I get the appropriate response for ftp.sendCommand("PASV"); but it times out on ftp.sendCommand("NLST"); finally giving me
425 Failed to establish connection.
I have tried to research the topic but most advice on this error is for people setting up servers (and it's usually a firewall problem).
Why does it work when net.ftp does it, but not when I send the commands manually?
Sending the PASV command manually is not enough, the client has to open the data connection to the port specified by the server in response to the PASV command. This is performed by calling the enterLocalPassiveMode() method. Since sending PASV manually doesn't initialize the data connection you get an error shortly after.
See http://slacksite.com/other/ftp.html#passive for more details on the FTP protocol.
I am getting the exception java.net.UnknowHostException:http://arbitrary-hero.dyndns.org/. I am attempting to connect to the address with a android client application I have made.
I have two computers one is running ubuntu 10.10 and the other is running windows 7. When I go to www.ipchicken.com on the windows 7 computer to check my ip I get 71.72.220.109 when I do a ifconfig from the command line on my linux machine I get 71.67.105.9. The 71.72.220.109 goes to my server application on the windows 7 computer the 71.67.105.9 and the address arbitrary-hero.dyndns.org goes to the apache server on my ubuntu 10.10 machine. The computers are in the same house using the same network and I dont understand why they have those different addresses. Also I am trying to get them to both use the URL.
String webserver = "71.67.105.9"; //does not work
String everythingelseinthehouse = "71.72.220.109"; //works
String weburl = "http://arbitrary-hero.dyndns.org/"; // does not work
Socket sock = new Socket (weburl , 13267);
//Socket sock = new Socket (address_everythingelse , 13267);
//Socket sock = new Socket (address_room , 13267);
This is where I declare my socket, sorry about the extra code but I have tried all possible combinations to make this work.
If you would like more code from me to help me solve this problem please ask I would be very happy to resolve this issue.
URL is not a host name, use InetAddress.getByName("something.dyndns.org") instead.
Other stuff about chickens is totally not clear in the question :)
Edit 0:
... when I do a ifconfig from the command line on my linux machine I get 71.67.105.9 ...
This tells me that your Linux box is either statically configured with this IP, or your router is setup to treat wired connections differently.
You need to add this premission to AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
Also, you need to use InetAddress for using the domain name instead of the IP address:
Socket sock = new Socket(InetAddress.getByName(weburl) , 13267);