Hi,
I'm using evapi to emit JSON blobs to share presence event transitions with a TCP client:
loadmodule "evapi"
modparam("evapi", "workers", 4) modparam("evapi", "bind_addr", "0.0.0.0:8010") modparam("evapi", "netstring_format", 0)
if($hdr(Event) eq 'dialog' && $cl > 0) { $xml(u=>doc) = $rb; $var(state) = $xml(u=>xpath:/di:dialog-info/di:dialog/di:state/text());
evapi_relay("{ "type": "state_transition", " ""sip_user": "$(fU{s.escape.common})", " ""sip_domain": "$(fd{s.escape.common})", " ""state": "$var(state)" }"); }
Every once in a while, however, my consumer service's JSON.parse() throws a parsing exception. There seems to be no particular pattern. When I investigated the actual string being sent, I found two objects concatenated:
JSON parsing exception: SyntaxError: Unexpected token { Raw received string was: { "type": "state_transition", "sip_user": "6789540671", "sip_domain": "sip.evaristesys.com", "state": "" }{ "type": "state_transition", "sip_user": "6789540671", "sip_domain": "sip.evaristesys.com", "state": "" }
Any ideas as to why this might happen?
Thanks,
-- Alex