Issue with Sending JSON Data via WebSocket in GAMA

16 views
Skip to first unread message

Imen Boussandel

unread,
May 21, 2025, 4:39:35 PMMay 21
to gama-p...@googlegroups.com

Dear all,

I hope this message finds you well.

I am currently working on a GAMA-based multi-agent simulation that communicates with an external Python server using WebSockets for reinforcement learning purposes.

I am encountering an issue when trying to send JSON-formatted data from GAMA to Python. I use the following code:

string json_data <- to_json(map_data);
do send to: "python_server" contents: json_data;

While the sending part seems to work, the messages received by the Python server contain unexpected internal GAMA tags such as:   @b@@r@... 

This makes the content unparsable as valid JSON, even though the string appears correct before sending.

I have tried several approaches

Using to_json() correctly

Filtering out non-JSON characters on the Python side

Ensuring the data structure is serializable

Checking if metadata is automatically added by GAMA during transmission.

Despite these efforts, the problem persists. My question is:

 Is there a recommended way in GAMA to send clean JSON strings over WebSockets without additional metadata?

Thank you very much for your time and support.

Best regards,

 

lesquoy....@gmail.com

unread,
Jul 3, 2025, 5:29:20 AMJul 3
to GAMA
Hello,

I think the problem you encountered is just that the connection on the gama side is not configured as "raw", which as a result encodes the messages in a specific way that is more suitable for communication between gama agents.
So I recommend you to try to set the raw parameter to true in the connect statement as described here.

Regards,

Baptiste
Reply all
Reply to author
Forward
0 new messages