Describe the bug
When using JSONTextMessageMapper with websocket and struct type, RapidJson Parse receive always empty rawmsg.
The empty message created here. The root cause looks due to passing payload string by reference which get cast to void* instead of passing char*.
potential fix tested: pass &payload[0]
To Reproduce
import csp
from csp import ts
from datetime import datetime, timedelta
from csp.adapters.websocket import JSONTextMessageMapper, WebsocketAdapterManager
class TopOfBook(csp.Struct):
u:int
symbol:str
b:str
B:str
a:str
A: str
@csp.graph
def g(uri: str):
print("Trying to connect to", uri)
ws = WebsocketAdapterManager(uri, verbose_log=True)
data = ws.subscribe(TopOfBook, JSONTextMessageMapper(),
push_mode=csp.PushMode.LAST_VALUE)
status = ws.status()
csp.print("status", status)
csp.print("data", data)
if __name__ == '__main__':
csp.run(g,
uri="wss://stream.binance.com:9443/ws/btcusdt@bookTicker",
starttime=datetime.utcnow(),
endtime=timedelta(minutes=1),
realtime=True)
Expected behavior
no error expected.
Error Message
empty message see above
Runtime Environment
import sys, csp; print(csp.version); print(sys.version); print(sys.platform)
0.0.3
3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:36:13) [GCC 12.3.0]
linux
Additional context
note that the version used was built locally from source using conda env as described in your wiki.
Describe the bug
When using JSONTextMessageMapper with websocket and struct type, RapidJson Parse receive always empty rawmsg.
The empty message created here. The root cause looks due to passing payload string by reference which get cast to void* instead of passing char*.
potential fix tested: pass &payload[0]
To Reproduce
Expected behavior
no error expected.
Error Message
empty message see above
Runtime Environment
import sys, csp; print(csp.version); print(sys.version); print(sys.platform)
0.0.3
3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:36:13) [GCC 12.3.0]
linux
Additional context
note that the version used was built locally from source using conda env as described in your wiki.