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!

Security Professional: Sharpen Your Defenses with These .conf25 Sessions

Sooooooooooo, guess what. .conf25 is almost here, and if you're on the Security Learning Path, this is your ...

First Steps with Splunk SOAR

Our first step was to gather a list of the playbooks we wanted and to sort them by priority.  Once this list ...

How To Build a Self-Service Observability Practice with Splunk Observability Cloud

If you’ve read our previous post on self-service observability, you already know what it is and why it ...