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
SplunkTrust
SplunkTrust

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
SplunkTrust
SplunkTrust

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!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...