PokemonGoBot icon indicating copy to clipboard operation
PokemonGoBot copied to clipboard

Websocket error when restarting bot

Open casper-gh opened this issue 10 years ago • 7 comments

When I restart a bot, I receive an error and the GUI can't load any data despite all boxes are there.

Steps to reproduce:

  1. Start the bot: java -jar $JAR_FILE_NAME > log.txt &
  2. Kill the bot: kill -9 $(ps aux | grep $JAR_FILE_NAME | grep -v 'grep' | awk '{print $2}')

Expected behavior: No error and GUI should be working

Actual behavior: GUI loads but no data

Stacktrace (If it's a crash):

Exception in thread "main" java.net.BindException: Address already in use
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:433)
        at sun.nio.ch.Net.bind(Net.java:425)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:125)
        at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:484)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1080)
        at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:430)
        at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:415)
        at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:903)
        at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:197)
        at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:350)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
        at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
        at java.lang.Thread.run(Thread.java:745)

Version: v0.5.0 alpha 3

Operating System: Ubuntu 14.04

Java version: 1.8

casper-gh avatar Jul 31 '16 17:07 casper-gh

Are you 100% sure nothing is using the posrt you set (default 8001) for the socket server? check netstat -an | grep 8001

langerhans avatar Jul 31 '16 17:07 langerhans

@langerhans it could be because I kill the java process so quickly that the port is still being used?

Because after a while the GUi works again

casper-gh avatar Jul 31 '16 18:07 casper-gh

I dont want to open a new issue for just a question. Too much spam already. But, how can i open the GUI?

I compile from dev. every time and run gradlew in cmd. Never saw the GUI. :/ Im noob on this stuff

Can i guys give me some Info? Thanks

qifbox avatar Jul 31 '16 19:07 qifbox

You can reach it with a web browser on http://ip:port

nostyler avatar Jul 31 '16 19:07 nostyler

@nostyler my pc ip? Thank you

Edit: already working. Thanks

qifbox avatar Jul 31 '16 19:07 qifbox

Yes, it can take a second or two for the bot to actually shut down and free the port. A SIGKILL doesn't leave the bot time to do this and the port might be freed up by the kernel later. Maybe try a SIGTERM and wait for the process to kill itself.

langerhans avatar Jul 31 '16 20:07 langerhans

@langerhans it takes about ~30m until I can see it something on GUI again, I guess the socket port is the culprit.

casper-gh avatar Jul 31 '16 22:07 casper-gh