Coder Social home page Coder Social logo

thegamecracks / berconpy Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 1.0 547 KB

An asynchronous Python wrapper over the BattlEye RCON protocol.

Home Page: https://berconpy.rtfd.org/

License: MIT License

Python 100.00%
asyncio battleye-rcon python python-library python3 rcon

berconpy's Introduction

berconpy's People

Contributors

draowyr avatar thegamecracks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

draowyr

berconpy's Issues

Potential InvalidStateError after prolonged connection failure

Observed Problem

An unusual exception may occur during runtime where the client attempts to set the result of a command already done, resulting in an asyncio.InvalidStateError.

Exception in callback _SelectorDatagramTransport._read_ready()
handle: <Handle _SelectorDatagramTransport._read_ready()>
Traceback (most recent call last):
  File "/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/python3.10/asyncio/selector_events.py", line 1027, in _read_ready
    self._protocol.datagram_received(data, addr)
  File "/berconpy/protocol.py", line 447, in datagram_received
    self._set_command(packet, message)
  File "/berconpy/protocol.py", line 245, in _set_command
    fut.set_result(message)
asyncio.exceptions.InvalidStateError: invalid state

This error occurred twice within a two hour span, and had been produced after the client was unable to connect to the server for 15 hours. It is unknown whether these were different futures, or if they were cancelled or had received duplicate responses. Majority of the log leading to the above error showed the client was unable to send commands or receive messages:

04:30:07: server has timed out (last received 46 seconds ago)
04:30:10: could not send command after 3 attempts
04:30:10: failed to receive players from server; player cache will not be available
04:31:24: server has timed out (last received 45 seconds ago)
04:31:27: could not send command after 3 attempts
04:31:27: failed to receive players from server; player cache will not be available

Afterwards the errors had discontinued, but the client was no longer connected to the server. Creating a new AsyncRCONClient was able to resolve the connection issue, but it may also have been resolved by calling AsyncRCONClient.connect() again.

Reproduction Steps

The steps to reproduce this are unclear, but it appears to happen after the network has temporarily lost connection.

System information

Python Version: Python 3.10.5+ (heads/3.10:2d33d217aa, Jun 19 2022, 00:12:44)
Operating System: Linux

Currently cannot connect to remote server

As of commit d4cf6d6, there appear to be issues communicating with remote servers. The protocol works for a local client/server simulation (see examples/server.py) and across two devices on the same network, but when attempting to connect to an actual remote server, no packets are received (datagram_received is not called) and eventually the connection attempts are exhausted.

Possible InvalidStateError when receiving command

This is a resurfacing of the InvalidStateError described in #2. On occasion, this error message may appear in the terminal:

Traceback (most recent call last):
  File "../python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "../python3.11/asyncio/selector_events.py", line 1161, in _read_ready
    self._protocol.datagram_received(data, addr)
  File "../python3.11/site-packages/berconpy/protocol.py", line 449, in datagram_received
    self._set_command(packet, message)
  File "../python3.11/site-packages/berconpy/protocol.py", line 241, in _set_command
    fut.set_result(message)
asyncio.exceptions.InvalidStateError: invalid state

This is not a fatal error (i.e. the messages following it continued to be handled correctly), but I am not sure how this could occur given how the protocol currently tries to avoid cancelling or setting the future more than once (see source).

System Information

Python version: Python 3.11.0 (main, Nov 11 2022, 20:51:20) [GCC 8.3.0] on linux
berconpy version: 1.1.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.