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
Super 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
Super 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!

Why You Can't Miss .conf25: Unleashing the Power of Agentic AI with Splunk & Cisco

The Defining Technology Movement of Our Lifetime The advent of agentic AI is arguably the defining technology ...

Deep Dive into Federated Analytics: Unlocking the Full Power of Your Security Data

In today’s complex digital landscape, security teams face increasing pressure to protect sprawling data across ...

Your summer travels continue with new course releases

Summer in the Northern hemisphere is in full swing, and is often a time to travel and explore. If your summer ...