Jump to content
View in the app

A better way to browse. Learn more.

Universal Devices Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Subscribing to events via Portal

Featured Replies

Posted

I seem to be having an issue with this.  I can send commands to the portal easy enough, but I can not seem to get a response from the portal when setting up a subscription to listen for events.  This same code works find when subscribing to the ISY directly.

private void doSubscribe(String auth) {

    SSLSocket isySocketSSL;
    Socket isySocket;

    try {
      if (aisy.getSSLEnabled()) {
        isySocketSSL = ConnectionManager.getSSLSocket(aisy);
        writer = new OutputStreamWriter(isySocketSSL.getOutputStream());
        reader = isySocketSSL.getInputStream();
      } else {
        isySocket = ConnectionManager.getSocket(aisy);
        writer = new OutputStreamWriter(isySocket.getOutputStream());
        reader = isySocket.getInputStream();
      }
    } catch (Exception e) {
      e.printStackTrace();
      return;
    }

    String subreq = "<s:Envelope><s:Body>" + "<u:Subscribe";
    subreq += " xmlns:u='urn:udi-com:service:X_Insteon_Lighting_Service:1'>";
    subreq += "<reportURL>REUSE_SOCKET</reportURL>";
    subreq += "<duration>infinite</duration>";
    subreq += "</u:Subscribe></s:Body></s:Envelope>";

    try {
      writer.write("POST /services HTTP/1.1\n");
      writer.write("Content-Type: text/xml; charset=utf-8\n");
      writer.write("Authorization: " + auth + "\n");
      writer.write("Content-Length: " + (subreq.length()) + "\n");
      writer.write("SOAPAction: urn:udi-com:device:X_Insteon_Lighting_Service:1#Subscribe\r\n");
      writer.write("\r\n");
      writer.write(subreq);
      writer.write("\r\n");
      writer.flush();
    } catch (IOException e) {
      e.printStackTrace();
      setRunning(false);
      return;
    }
    
    int content_length = 0;
    StringBuffer headerBuffer = new StringBuffer();
    int charValue;
    do { //Do once and then check for SID - REPEAT IF SID FOUND
      try {
//THIS IS AS FAR AS IT GETS - reader never gets any response data.
        while ((charValue = reader.read()) != -1) { //CONTINUE READING TILL END OF INPUT
          //DO STUFF
        }
      } catch (Exception e) {
        e.printStackTrace();
        Log.d(TAG,"Network Connection Lost");
        hasSID = false;
        if (listener != null)
          listener.onConnectionFailure();
      }
      headerBuffer.setLength(0);
    } while (hasSID);
    if (listener != null)
      listener.onConnectionFailure();
  }
  • Author

Hi James,

 

1. What URL are you posting to?

2. Do you have Preferred ISY set in My Profile (my.isy.io/top right corner)?

 

With kind regards,

Michel

 

I was able to resolve this:  My SOAP knowledge is very limited so I don't really know shat I am doing with it.  

 

I changed my request to :

writer.write("POST /services HTTP/1.1\n");
      writer.write("Content-Type: text/xml; charset=utf-8\n");
      writer.write("Host: " + isy.getHost());
      writer.write("Authorization: " + auth + "\n");
      writer.write("Content-Length: " + (subreq.length()) + "\n");
      writer.write("\r\n");
      writer.write("\r\n");
      writer.write(subreq);
      writer.write("\r\n");
      writer.flush();

I guess I was adding some extra information that did not need to be included.  The ISY didn't mind, but it appears that the portal did.  

Guest
This topic is now closed to further replies.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.