# How to send message to a remote gateway from module

**URL:** <https://forum.inductiveautomation.com/t/how-to-send-message-to-a-remote-gateway-from-module/12197>\
**Category:** 3rd Party Modules\
**Created:** [October 4, 2016, 6:57pm UTC](https://forum.inductiveautomation.com/t/how-to-send-message-to-a-remote-gateway-from-module/12197 "2016-10-04T18:57:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmclean2](https://avatars.discourse-cdn.com/v4/letter/p/9de0a6/32.png) [@pmclean2](https://forum.inductiveautomation.com/u/pmclean2)\
**Post date:** [October 4, 2016, 6:57pm UTC](https://forum.inductiveautomation.com/t/how-to-send-message-to-a-remote-gateway-from-module/12197/1 "2016-10-04T18:57:26Z")

</div>

Hi,

From a previous post (August 26, 2016) where you give the following code to send a message from a module, I tried to use the same thing to send a message to a remote gateway but it seems that the remoteServers property doesn’t exist on the filter properties available in the SDK. Is it possible or I miss something?

Thanks

Code:  
MessageDispatchManager mdm = gatewayContext.getMessageDispatchManager();

PyDictionary payload = new PyDictionary(new PyObject[] {  
new PyString(“Source”), new PyString(“Gateway”),  
new PyString(“Message”), new PyString(“testMessage”)  
});

// Limit to Gateway scope  
Properties filterParams = new Properties();  
filterParams.setProperty(MessageDispatchManager.KEY\_SCOPE, MessageDispatchManager.SCOPE\_GATEWAY\_ONLY);

// You must specify a project, as message handlers are configured in projects.  
mdm.dispatch(“MyProject”,  
“MyMessageHandler”,  
payload,  
filterParams);

---

<div class="post-metadata">

**Author:** ![mgross](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mgross/32/3311_2.png) [@mgross](https://forum.inductiveautomation.com/u/mgross)\
**Post date:** [October 5, 2016, 3:10pm UTC](https://forum.inductiveautomation.com/t/how-to-send-message-to-a-remote-gateway-from-module/12197/2 "2016-10-05T15:10:46Z")

</div>

Note that the remote servers function was added in 7.8.2, so make sure you are using a recent 7.8 version. That being said, give this a try:

```auto
// Convert the list of servers into a single comma-delimited String
StringBuffer buffer = new StringBuffer();
for(String server: remoteServers){
    if(buffer.length() != 0){
        buffer.append(",");
    }
    buffer.append(server);
}
String remoteServersStr = buffer.toString();

// Limit to Gateway scope
Properties filterParams = new Properties();
filterParams.setProperty(MessageDispatchManager.KEY_SCOPE, MessageDispatchManager.SCOPE_GATEWAY_ONLY);

// Add the remote servers String
filterParams.setProperty(MessageDispatchManager.KEY_REMOTE_SERVERS, remoteServersStr);
```
