Message Boards Message Boards

Send message outside Mathematica through Channel-Based Network?

GROUPS:

Channel-Based communication is available since release 11.0 as an experimental functionality for publish-subscribe communication between WL sessions or with external systems.

Functionality works well between WL sessions, but when trying to send messages through external systems, I was unable to make this work.,

myChannel = CreateChannel["demo", Permissions -> "Public"]
(*ChannelObject["https://channelbroker.wolframcloud.com/users/user@example.com/demo"]*)

listener = ChannelListen[myChannel];
Dynamic[listener["Message"]]

ChannelSend[myChannel, <|key -> "test"|>]
(*Message Successful*)

Prepare command for curl (or web browser)
url = URLBuild[listener["URL"], {"operation" -> "send", "Message" -> "yet another message"}]

(*"https://channelbroker.wolframcloud.com/users/user%40example.com/demo?operation=send&Message=another+message"*)

(*Sending Message through the Mathematica Session works*)
URLExecute[url]
(*message ID*)

When trying through terminal with curl URL, or through the web browser, or other languages in the same computer, or another device, the following message is displayed:

403 Forbidden

Please, can you test this on your system to see if the same issue is found in your computer system?

Mathematica version 11.x

POSTED BY: Diego Zviovich
Answer
5 months ago

Hi Diego,

What are the permissions of the channel you are trying to send? To send a message through say a web browser, or other HTTP client, the channel needs to be publically writable, with Permissions-><|"All"->"Write",...|>

Let me know if that works for you, but note that doing this will let anyone send any message on your channel.

Thanks,

Ian

POSTED BY: Ian Johnson
Answer
5 months ago

Ian, this is are the options of the channel

<|ChannelPreSendFunction -> Automatic, HandlerFunctions -> None, 
 Initialization -> Automatic, 
 MetaInformation -> <|"OwnerID" -> "users@example.com"|>, 
 NotificationFunction -> Inherited, 
 Permissions -> <|All -> {"Write", "Read"}, 
   "user@example.com" -> "Execute"|>, 
 ChannelBase -> "https://channelbroker.wolframcloud.com:443", 
 "URLRendering" -> Automatic|>
POSTED BY: Diego Zviovich
Answer
5 months ago

Hi Ian, the permissions read,

Permissions -> <|All -> {"Write", "Read"}, "myemail@gmail.com" -> "Execute"|>

POSTED BY: Diego Zviovich
Answer
5 months ago

When copying a URL to external programs, make sure that you are using Edit > Copy As > Plain Text (Cmnd-Shift-C on Mac)... or otherwise remove the line continuation characters ("\") that the Front End inserts in the copied text.

As yet another trick, you can execute:

Hyperlink[url]

... and then click the output link. That will use the correct URL in your default web browser.

POSTED BY: Igor Bakshee
Answer
5 months ago

Group Abstract Group Abstract