Can I handle a failing stream socket in the frontend?

I’m developing a live data source and am having problems reconnecting to a broken stream. Because my data source allows for a fair amount of query customization, I cannot fit the entire request in a stream URL. To get around this, I’m storing the query in memory and hashing it into an ID which is used to look it up. If the plugin crashes, the ID to query link disappears, but the client can regenerate it by sending another query.

The problem is that I am not sure how or if the frontend knows when a stream is severed. The websocket chatter does not seem to indicate a failure anywhere. The backend, on the other hand, repeatedly tries to kickstart the stream from its URL.

func (d *Datasource) RunStream(ctx context.Context, req *backend.RunStreamRequest, sender *backend.StreamSender) error {
	qm, ok := d.streams[req.Path]
	if !ok {
		return fmt.Errorf("runstream called on missing stream %s", req.Path)
	}
    ...
}

If the error condition is met, the backend just spits this message out again and again.

ERROR[03-07|14:47:35] Error running stream, re-establishing    logger=live.runstream

I need some way to include and retrieve additional context in the StreamHandler.RunStream method (so I can actually run the stream again) or a way to alert the front end that a failure has occurred. Is this possible?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.