Exception when trying to connect VisualVM

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
lggstef
Posts: 10
Joined: 14 Jun 2019, 20:13

Exception when trying to connect VisualVM

Post by lggstef »

Hello,

I've been trying to connect VisualVM to our SmartFox server following the guide here: http://docs2x.smartfoxserver.com/Advanc ... ive-server for connecting to a remote server (our SmartFox server is running in a Jelastic environment). I added the necessary parameters and made sure the firewall has inbound and outbound rules allowed for the jmx port, and it refuses to connect. After many unsuccessful attempts, I checked the logs on the admin and realized that I was getting an exception every time I tried to connect VisualVM:

Code: Select all

java.lang.IllegalArgumentException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.IllegalArgumentException
Message: Incoming request size too large: 1380796672, Current limit: 500000, From: { Id: 4, Type: DEFAULT, Logged: No, IP: 172.18.1.201:56785 }
Sender: { Id: 4, Type: DEFAULT, Logged: No, IP: 172.18.1.201:56785 }
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.protocol.binary.BinaryIoHandler.validateIncomingDataSize(BinaryIoHandler.java:527)
com.smartfoxserver.v2.protocol.binary.BinaryIoHandler.handleDataSize(BinaryIoHandler.java:295)
com.smartfoxserver.v2.protocol.binary.BinaryIoHandler.handleRead(BinaryIoHandler.java:183)
com.smartfoxserver.v2.protocol.SFSIoHandler.onDataRead(SFSIoHandler.java:143)
com.smartfoxserver.bitswarm.core.SocketReader.readTcpData(SocketReader.java:336)
com.smartfoxserver.bitswarm.core.SocketReader.readIncomingSocketData(SocketReader.java:220)
com.smartfoxserver.bitswarm.core.SocketReader.run(SocketReader.java:171)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
SFS version: 2.13.1
Client API: C# and Unity, version 1.5.0

Any idea why I'd be getting this exception when trying to connect VisualVM? Let me know if there's any other info you need. Thanks
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Exception when trying to connect VisualVM

Post by Lapo »

If the VisualVM connection is the cause of that error then you're connecting to the wrong TCP port (with VisualVM)
The only reason why SFS2X would respond to a VisualVM connection is if you're using SFS2X's own socket port to perform the connection, which is obviously incorrect.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
lggstef
Posts: 10
Joined: 14 Jun 2019, 20:13

Re: Exception when trying to connect VisualVM

Post by lggstef »

Hi Lapo,

Ah yes, I was indeed using the incorrect port, which gets rid of the exception. Sorry about that. I am, however, still unable to connect VisualVM using the port that I made for jmx (the one set here: -Dcom.sun.management.jmxremote.port=xxxx). In terms of errors, this is what I see in VisualVM's log:

Code: Select all

INFO [com.sun.tools.visualvm.jmx.impl.JmxModelImpl]: connect(service:jmx:rmi:///jndi/rmi://xxxxxxxxxx.njs.jelastic.vps-host.net:xxxx/jmxrmi)
java.net.ConnectException: Connection timed out: connect
	at java.net.DualStackPlainSocketImpl.connect0(Native Method)
	at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:673)
	at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:432)
	at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:88)
	at javax.rmi.ssl.SslRMIClientSocketFactory.createSocket(SslRMIClientSocketFactory.java:121)
	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
Caused: java.rmi.ConnectException: Connection refused to host: xxxxxxxxxx.njs.jelastic.vps-host.net; nested exception is: 
	java.net.ConnectException: Connection timed out: connect
	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
	at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
	at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
	at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:338)
	at sun.rmi.registry.RegistryImpl_Stub.lookup(RegistryImpl_Stub.java:112)
	at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:132)
Caused: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: xxxxxxxxxx.njs.jelastic.vps-host.net; nested exception is: 
	java.net.ConnectException: Connection timed out: connect]
	at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:136)
	at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:205)
	at javax.naming.InitialContext.lookup(InitialContext.java:417)
	at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1955)
	at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1922)
	at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:287)
Caused: java.io.IOException: Failed to retrieve RMIServer stub
	at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:369)
	at com.sun.tools.visualvm.jmx.impl.JmxModelImpl$ProxyClient.tryConnect(JmxModelImpl.java:553)
[catch] at com.sun.tools.visualvm.jmx.impl.JmxModelImpl$ProxyClient.connect(JmxModelImpl.java:487)
	at com.sun.tools.visualvm.jmx.impl.JmxModelImpl.connect(JmxModelImpl.java:215)
	at com.sun.tools.visualvm.jmx.impl.JmxModelImpl.<init>(JmxModelImpl.java:204)
	at com.sun.tools.visualvm.jmx.impl.JmxModelProvider.createModelFor(JmxModelProvider.java:40)
	at com.sun.tools.visualvm.jmx.impl.JmxModelProvider.createModelFor(JmxModelProvider.java:21)
	at com.sun.tools.visualvm.core.model.ModelFactory.getModel(ModelFactory.java:91)
	at com.sun.tools.visualvm.tools.jmx.JmxModelFactory.getJmxModelFor(JmxModelFactory.java:49)
	at com.sun.tools.visualvm.jmx.impl.JmxApplicationProvider.addJmxApplication(JmxApplicationProvider.java:281)
	at com.sun.tools.visualvm.jmx.impl.JmxApplicationProvider.createJmxApplication(JmxApplicationProvider.java:186)
	at com.sun.tools.visualvm.jmx.JmxApplicationsSupport.createJmxApplicationImpl(JmxApplicationsSupport.java:299)
	at com.sun.tools.visualvm.jmx.JmxApplicationsSupport.createJmxApplicationInteractive(JmxApplicationsSupport.java:276)
	at com.sun.tools.visualvm.jmx.impl.AddJMXConnectionAction$1.run(AddJMXConnectionAction.java:60)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1384)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1994)
Looks like the connection's refused and therefore times out. Perhaps I'm setting up something incorrectly on the Jelastic side.
Thanks for the help :)
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Exception when trying to connect VisualVM

Post by Lapo »

Can you show me the extra JVM settings you're using to enable the remote VisualVM connection from the SFS2X side?
Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
lggstef
Posts: 10
Joined: 14 Jun 2019, 20:13

Re: Exception when trying to connect VisualVM

Post by lggstef »

I tried adding a public IP to the jelastic environment (as opposed to using the endpoint they set up automatically) and it still fails. Here are the options I added to the JVM:

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=99XX
-Dcom.sun.management.jmxremote.rmi.port=99XX
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=216.154.220.XX

And I try to connect in VisualVM using 216.154.220.XX:99XX
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Exception when trying to connect VisualVM

Post by Lapo »

I've setup an SFS2X instance on an EC2 server (w/ Ubuntu 18) and attempted a remote connection with VisualVM.
Everything works as expected.

Settings used:

Code: Select all

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=5000
-Dcom.sun.management.jmxremote.rmi.port=5000
-Djava.rmi.server.hostname=[external-ip-address]
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
Before connecting I had to setup the firewall to allow traffic on TCP port 5000.

Just to be clear the 99XX port value you're using is NOT the SFS2X port value, right?
To double check that the machine is actually reachable on port 99XX try telnetting the remote server on that port:

Code: Select all

telnet <ip-addr> 99XX
If it doesn't connect then you need to check your firewalls, both on your client and server.

Let us know
Lapo
--
gotoAndPlay()
...addicted to flash games
lggstef
Posts: 10
Joined: 14 Jun 2019, 20:13

Re: Exception when trying to connect VisualVM

Post by lggstef »

So it was indeed a firewall issue, as telnet couldn't connect to it either. As it turns out, older jelastic environments didn't allow the ability to modify the firewall. It was a feature added afterwards and isn't compatible with the older environments. So what I did was start a new one from scratch so I could modify the firewall myself. I allowed traffic on port 99XX (not the smartfox port :P ), and now VisualVM can connect to it and I can finally profile my game.

Thanks for all the help!
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Exception when trying to connect VisualVM

Post by Lapo »

Excellent! :)
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply