Splunk Dev

reply/response in PersistentServerConnectionApplication

Schroeder
Explorer

Hi,

how can I reply to the sending endpoint not using return as I want to keep the connection open?

My endpoint works as long as I respond via the return through the appserver but I do not want to close the connection. I tried using yield with json.dumps but then the appserver throws a serialization error.

Doing this async it also something the appserver does not like.

How can I do something like:

response {'a':'1'}

... do something

return {'a':'2'}

Sample, this works:

return {'payload': '','status': 200}
 
and this does not:

yield jsons.dumps({'payload': '','status': 200})
 
Thanks Peter
0 Karma

livehybrid
Ultra Champion

Hi @Schroeder 

In your restmap.conf have you set stream=true? I'm not sure if this is the only thing you would need to change but it could be a good starting point!

https://help.splunk.com/en/splunk-enterprise/administer/admin-manual/9.4/configuration-file-referenc...

stream = <boolean>
* Describes whether or not splunkd sends the payload in the
request to the driver in a streaming fashion.
* A value of "true" means splunkd sends the payload in the
request to the driver in a stream, or multiple sequential requests.
* A value of "false" means splunkd sends the payload in the
request to the driver as a field of the original request.
* Only has effect if the 'scripttype' setting is set to "persist".
* Default: false

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma

Schroeder
Explorer

Hi!

No, I did not. Does that mean I could then use yield?

I have a hard way to find good examples for me use case.

//Peter

0 Karma

livehybrid
Ultra Champion

Hi @Schroeder 

I've been trying to get this to work but unfortunately not managed to. It looks like this is designed for streamed payload being sent into the persistconn/appserver.py rather than as a response to the browser.

Please let us know if you do manage to get anywhere with this though - Perhaps its possible with a custom driver = value, although there arent many examples of this online!

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma
Get Updates on the Splunk Community!

Leveraging Detections from the Splunk Threat Research Team & Cisco Talos

  Now On Demand  Stay ahead of today’s evolving threats with the combined power of the Splunk Threat Research ...

New in Splunk Observability Cloud: Automated Archiving for Unused Metrics

Automated Archival is a new capability within Metrics Management; which is a robust usage & cost optimization ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...