[Py4j-users] Error when accessing jvm for basic sample (take 2)
Status: Beta
Brought to you by:
barthe
|
From: bn <av...@ya...> - 2011-10-24 02:04:48
|
Hi,
I seem to be having this issue also, having written a small
program which runs fine in linux but gets 'connection refused' in win7 64bit.
So I tried the AdditionApplication example with the win7
firewall turned off (see console A output below), then attempted to connect from python where I also get a socket.error 10061 (console B output below). As you can see netstat shows that 192.168.1.39:25333 status is 'LISTENING' after I exit python.
Trying a different port gives the same error. Initially I thought it may somehow have to do with mixing 32bit java and 64bit python, but switching python to 32bit didn't help. I don't know much about sockets and would appreciate any insight here.
thanks,
-Bahman
---------------------------
console A:
---------------------------
>java -version
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)
>netsh advfirewall set allprofiles state off
Ok.
>java -cp lib\py4j0.7.jar;AdditionApplication-0.1.jar AdditionApplication
---------------------------
console B:
---------------------------
>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from py4j.java_gateway import JavaGateway
>>> gateway = JavaGateway()
>>> a = gateway.entry_point
>>> a.addition(1,2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 430, in __call__
answer = self.gateway_client.send_command(command)
File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 257, in send_command
connection = self._get_connection()
File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 213, in _get_connection
connection = self._create_connection()
File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 220, in _create_connection
connection.start()
File "F:\Programs\Python27\lib\site-packages\py4j-0.7-py2.7.egg\py4j\java_gateway.py", line 318, in start
self.socket.connect((self.address, self.port))
File "F:\Programs\Python27\lib\socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it
>>> ^Z
>netstat -an
Active Connections
Proto Local Address Foreign Address State
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING
TCP 0.0.0.0:554 0.0.0.0:0 LISTENING
TCP 0.0.0.0:2869 0.0.0.0:0 LISTENING
TCP 0.0.0.0:10243 0.0.0.0:0 LISTENING
TCP 0.0.0.0:49152 0.0.0.0:0 LISTENING
TCP 0.0.0.0:49153 0.0.0.0:0 LISTENING
TCP 0.0.0.0:49154 0.0.0.0:0 LISTENING
TCP 0.0.0.0:49155 0.0.0.0:0 LISTENING
TCP 0.0.0.0:49156 0.0.0.0:0 LISTENING
TCP 0.0.0.0:49157 0.0.0.0:0 LISTENING
TCP 0.0.0.0:49164 0.0.0.0:0 LISTENING
TCP 0.0.0.0:54465 0.0.0.0:0 LISTENING
TCP 127.0.0.1:1299 0.0.0.0:0 LISTENING
TCP 127.0.0.1:49160 0.0.0.0:0 LISTENING
TCP 127.0.0.1:49293 127.0.0.1:49294 ESTABLISHED
TCP 127.0.0.1:49294 127.0.0.1:49293 ESTABLISHED
TCP 127.0.0.1:49297 127.0.0.1:49298 ESTABLISHED
TCP 127.0.0.1:49298 127.0.0.1:49297 ESTABLISHED
TCP 127.0.0.1:49570 127.0.0.1:49160 TIME_WAIT
TCP 192.168.1.39:139 0.0.0.0:0 LISTENING
TCP 192.168.1.39:25333 0.0.0.0:0 LISTENING
TCP 192.168.1.39:49360 168.143.242.112:80 CLOSE_WAIT
TCP 192.168.1.39:49563 72.14.204.147:80 ESTABLISHED
TCP [::]:135 [::]:0 LISTENING
TCP [::]:445 [::]:0 LISTENING
TCP [::]:554 [::]:0 LISTENING
TCP [::]:2869 [::]:0 LISTENING
TCP [::]:10243 [::]:0 LISTENING
TCP [::]:49152 [::]:0 LISTENING
TCP [::]:49153 [::]:0 LISTENING
TCP [::]:49154 [::]:0 LISTENING
TCP [::]:49155 [::]:0 LISTENING
TCP [::]:49156 [::]:0 LISTENING
TCP [::]:49157 [::]:0 LISTENING
TCP [::]:49164 [::]:0 LISTENING
TCP [::]:54465 [::]:0 LISTENING
---------------------------
AdditionApplication.java:
---------------------------
import py4j.GatewayServer;
public class AdditionApplication {
public int addition(int first, int second) {
return first + second;
}
public static void main(String[] args) {
AdditionApplication app = new AdditionApplication();
// app is now the gateway.entry_point
GatewayServer server = new GatewayServer(app);
server.start();
}
}
---------------------------
|