Comments (6)
These changes will more or less be incorporated into a rewrite of the RCON module.
from python-valve.
My server is running on Linux, the player name in response may contains non-ascii char.
So I changed default encoding from ascii
to utf-8
in rcon.py
, and it works well.
And I just checked other libraries, all of that used utf-8
encoding.
- https://github.com/aiusepsi/SourceRcon/blob/stable/SourceRconLib/SourceRcon.cs#L320
- https://github.com/ScottKaye/CoreRCON/blob/master/src/CoreRCON/PacketFormats/RCONPacket.cs#L50
- https://github.com/ribasco/async-gamequery-lib/blob/master/protocols/valve/source/query/src/main/java/com/ibasco/agql/protocols/valve/source/query/packets/response/SourcePlayerResponsePacket.java#L46
- https://github.com/Kronos666/rkon-core/blob/master/src/net/kronos/rkon/core/Rcon.java#L32
from python-valve.
Any update on this one? I tried changing rcon.py
from ascii
to utf-8
and am presented with this error:
Unexpected message <RCONMessage 0 AUTH_RESPONSE 0B>
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 994-996: ordinal not in range(128)
Quite unhelpful. I'm not sure why ascii
is even still being used.
I've tried pretty much everything mentioned in the docs. I can't run valve.rcon.RCON.execute()
without this error - I don't even get a chance to encode/decode with my desired format.
from python-valve.
I've hit this issue yesterday. I have my own web interface for the server I'm running, which is dependent on this package. It was stable as hell until someone joined a server with a weird chars in his name. That's when simpe status
request was crashing my app:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "./application.py", line 45, in decorator
return f(*args, **kwargs)
File "./application.py", line 73, in index
data = rcon('status')
File "/usr/local/lib/python2.7/dist-packages/valve/rcon.py", line 346, in __call__
raise RCONMessageError("Couldn't decode response: {}".format(exc))
valve.rcon.RCONMessageError: Couldn't decode response: 'utf8' codec can't decode byte 0xd0 in position 359: invalid continuation byte
After looking into detalis a bit further it does not matter what encoding you are using - you might hit this issue in any case. IMO, quick (right?) solution would be to simply drop those chars that can't be encoded:
text.encode(encoding=self.ENCODING, errors='ignore')
I'll create a PR, and then it's up to you to decide what would be the correct way to do this.
from python-valve.
Here you go. Feel free to update a commit message if needed.
from python-valve.
For others who may find this in the future, this is what I found a solution in:
First, read https://python-valve.readthedocs.io/en/latest/rcon.html#unicode-and-string-encoding
with valve.rcon.RCON(server_address, password) as rcon:
rcon_resp = rcon('status')
rcon_text = rcon_resp.body.decode('utf-8', 'ignore')
This works for me on a Ubuntu 18 LTS server running this under Python 3.6 against SRCDS running on the same instance.
from python-valve.
Related Issues (20)
- TF2 server returning fragments with the compressed flag, but the fragments aren't compressed? HOT 3
- Switch message decoding from declarative to imperative syntax HOT 1
- rcon against local ark server times out HOT 2
- Arma III timeout HOT 3
- UDP Support
- A2S_RULES contains binary data for Arma 3 servers HOT 5
- I need some support HOT 1
- Receive window can be too small HOT 2
- valve.source.messages.BufferExhaustedError: No string terminator HOT 5
- Are non-source servers supported? ServerQuerier (Mordhau timeout) HOT 2
- A2S Ping broken by typo HOT 2
- No handlers could be found for logger "valve.rcon"
- ModuleNotFoundError: No module named 'six' HOT 1
- Unexpected message <RCONMessage 0 AUTH_RESPONSE 0B> HOT 3
- valve rcon ConnectionRefusedError: [WinError 10061]
- Is this still maintained? HOT 5
- python-valve is reporting an error when there is none
- CS 1.6 problem with some servers HOT 2
- Update in A2S_INFO packet (added challenge) HOT 2
- ServerQuerier - Invalid value (65) for field 'response_type' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-valve.