Topinambur223606 / PixelPlanetTools

Bot for pixelplanet.fun. Partially based on woyken/pixelplanet.fun-bot
36 stars 13 forks source link

[ERROR] Websocket connection closed, trying to reconnect when running bot via torsocks on Ubuntu #25

Closed carpet92 closed 4 years ago

carpet92 commented 4 years ago

Okay. It is possible to run bot using mono on Ubuntu 18.04.1 (WSL on Windows 10) and it's working fine but ... When I trying to run it via tor using torsocks I got error message in terminal: [ERROR] Websocket connection closed, trying to reconnect...

Log:

06:30:20.790  [UPDATE]        Checking for updates...
06:30:27.726  [UPDATE]        Already up to date
06:30:27.740  [TECHSTATE]     Downloading image...
06:30:27.740  [DEBUG]  T1   | PixelColorsByUri(): URI - right.jpg
06:30:27.839  [TECHINFO]      Image is downloaded
06:30:27.839  [TECHSTATE]     Converting image...
06:30:27.842  [TECHINFO]      Image is converted
06:30:27.843  [TECHSTATE]     Calculating pixel placing order...
06:30:27.856  [TECHINFO]      Pixel placing order is calculated
06:30:27.857  [TECHSTATE]     Calculating list of chunks...
06:30:27.875  [TECHINFO]      Chunk list is calculated
06:30:27.876  [DEBUG]  T23  | StatsCollectionThreadBody() started
06:30:27.880  [TECHSTATE]     Connecting via websocket...
06:30:29.919  [DEBUG]  T1   | Websocket log message: , Not a WebSocket handshake response.
06:30:29.924  [DEBUG]  T1   | WebSocket_OnClose(): start
06:30:29.924  [DEBUG]  T1   | WebSocket_OnClose(): invoking OnConnectionLost
06:30:29.924  [ERROR]         Websocket connection closed, trying to reconnect...
06:30:30.880  [TECHSTATE]     Connecting via websocket...

I configured torrc exactly right. Because sometimes I use tor as a system SOCKS proxy.

I also opened the tor socks listener port for public (I have public IP address) but it wasn't have effect.

Steps to reproduce on Ubuntu 18.04:

  1. Install mono-complete https://www.mono-project.com/download/stable/#download-lin
  2. run mono PixelPlanetBot.exe run etc.
  3. sudo apt-get install tor
  4. run tor or sudo service tor start in terminal
  5. sudo apt-get install torsocks
  6. torsocks mono PixelPlanetBot.exe run etc.

Also I have experienced same issue in Whonix OS. The Whonix OS force all outgoing traffic through the Tor anonymity network by design.

Steps to reproduce on Whonix OS:

  1. sudo apt install mono-complete
  2. just run mono PixelPlanetBot.exe run etc.

Screenshots:

Screenshot (64)

Screenshot (65)

Topinambur223606 commented 4 years ago

According to logs, it looks like there are some problems with initiating connection via websocket. Firstly, please try to access and use PixelPlanet from browser while connecting through Tor. If it does not work, then it is probably external cause - either Tor itself or PixelPlanet. Also, websocket connection used by bot is handled by third-party library. If PixelPlanet works fine in browser, I guess it can be limitation of that library. If so, I can try replacing it with another one.

Topinambur223606 commented 4 years ago

Hello @Zx-EvM, Is the issue still relevant?

carpet92 commented 4 years ago

@Topinambur223606 it is looks like pixelplanet detect and blocks access for "harmful" IPs via special APIs

https://github.com/pixelplanetdev/pixelplanet/blob/master/src/core/isProxy.js#L17-L50 https://github.com/pixelplanetdev/pixelplanet/blob/master/src/core/isProxy.js#L59 https://github.com/pixelplanetdev/pixelplanet/blob/master/src/core/isProxy.js#L86

Topinambur223606 commented 4 years ago

If I recall correctly, PixelPlanet does not drop the connection if proxy is detected; instead, it refuses to place pixels. However, implementation could have been changed or websocket connection could be interrupted somehow by Tor itself. I think we still need to check if websocket connection works in browser when connected through Tor network; if so, it is definitely the bot issue.

carpet92 commented 4 years ago

@Topinambur223606 okay. Tor browser itself does not open pixelplanet website at all. But if I use tor socks or tor https proxy in Windows proxy configuration (for make chrome works via tor proxy) I just have got infinity captcha and can not place pixel.

Topinambur223606 commented 4 years ago

Well, I guess infinite captcha is the indicator of unstable websocket connection, which confirms my earlier assumptions. Taking into account that:

I think that we can consider PixelPlanet to be impossible to use over Tor network. Therefore, it is not a bot issue.