Skip to content

Graceful handling of incomplete streaming line data #4

@ghost

Description

I've recently seen some errors in the streaming api with message
"unhandled event MessageChunk(Bytes(),) in state Disconnected"
where xxx is a number.
Looking at the earlier log messages this seems to have been caused by some invalid JSON trying to be parsed in my case it was - {"tick":{"instrumen . I'm guessing an incomplete line was sent from Oanda.

Looking at StreamingConnector.scala line 112 the statement line.parseJson.asJsObject.fields.head assumes the line is valid JSON in order to parse correctly. In the case it is not valid JSON an json exception is thrown in - spray.json.JsonParsersParsingException.

A possible work around may be to put a catch around line.parseJson.asJsObject.fields.head and return a Option[JSON] which could then be an additional case to match against.

Hope this all makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions