Perspective Gateway Message Handler with File Upload Component

I'm attempting to message file data from a perspective client to the gateway for further processing. I'm using the file upload component and the file is a CSV file. I'm logging the perspective session as well as on the gateway message side. The perspective session logs but the gateway for the message handler never logs which tells me that the message handler is never evoked.

The perspective side

The gateway side

And on my gateway log
image

And this is the extend of what I get with the attempt. Am I missing something for getting the gateway handler to work with perspective. Once I get this working then I can complete the reset of the code.

You are trying to use the syntax and options for system.util.sendMessage() with system.perspective.sendMessage(). The latter only works within a Perspective session to send messages within the session/page/view.

I presume you are trying to send to a different gateway? (Because the file upload event runs in the gateway the Perspective client is running from, and can therefore do anything a message handler can do in that gateway.)

{Consider using system.util.sendRequest() so that you can return success/failure/whatever to indicate to the client.}

1 Like

Changed my code to this

And now my gateway log does this

image

From what I can conclude is that the Gateway message handler will listen to calls from system.util.sendMessage called from a perspective session. I was not expecting this.

You aren't sending to a different gateway. Why are you bothering to use a message handler?

1 Like

Honestly. Perspective back to the gateway to run a dataset at the gateway. Why not!

Because perspective is already running on the gateway.

2 Likes

This is the important bit.
All scripts and bindings in "Perspective" are actually executing on the gateway already, because web browsers can't [1] run Python directly. So we've already sent the file data to the backend during the file upload operation by the time your script is invoked. There's no need to wrap it up and send it anywhere via a message handler, and in fact it's a hugely expensive operation that should be avoided as much as possible. You should kick off (possibly async) a project library script to handle your uploaded file data direct from the upload handler.


  1. Don't test me, pedants ↩ī¸Ž

4 Likes