Jump to content

Socket Connection multiple ISYs


Javi

Recommended Posts

I just go around to installing multiple ISY on my portal account and have run into a problem.  It appears that no matter which "URL to ISY" I use the (SOAP) socket will always connect to "My preferred ISY".  This is not an issue with REST.  If I delete "My preferred ISY" i get a Code 400 "Preferred ISY not set on user profile".

 

How can we direct a socket connection to a specific ISY? 

 

Link to comment

I tested it and can't reproduce this problem.

Are you sure you are using the URL to ISY as taken from the ISY information dialog? Are you using the admin console, or something else? Please provide more information on the SOAP call you are trying.

Just an FYI, you can do SOAP request WITHOUT having the ISY code in the URL. In this case, it will use the preferred ISY. If the preferred ISY is not set, it would indeed give you such an error message.

But if the ISY code is in the URL, this is what will be used to identify the destination ISY.

Link to comment

Thanks @bmercier

I am short of time today but now that I know it is on my side (again) I will try to find a fix in my code.  This is for a a native android app (Java) and I was going off my my logs which did not show the actual socket request. Upon looking at my request the socket was using the host (url.getHost)  which removed the endpoint.  I am using the SSLSocketFactory Library so I may have to use a different library as it appears this only accepts the host and not an endpoint.

Thanks again for your time!

Javier

Link to comment

@bmercier I am running into a couple of problems.  I  tried to use HttpURLConnection but the line "Post reuse HTTP/1.1" in the header before the first <Event>...</Event>  will throw an exception so I guess I have to stick with SSLSocketFactory (or SocketFactory for local)  for the raw output.   So my question is,  Can the URL to ISY be placed in the request header?

 

POST /isy/url_to_isy/services HTTP/1.1
Host: my.isy.io  
Content-Type: text/xml; charset=utf-8
Authorization: Basic base64UsernamePassword
Content-Length: 192
SOAPAction: urn:udi-com:device:X_Insteon_Lighting_Service:1#Subscribe

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

Making a request with the header/envelope above will return either

" HTTP/1.1 500 Internal Server Error" "Invalid response header received from ISY"

on the first request, then

"HTTP/1.1 817 unknown" "<?xml version="1.0" encoding="UTF-8"?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body><UDIDefaultResponse><status>817</status><info>n/a</info></UDIDefaultResponse></s:Body></s:Envelope>"

on subsequent requests.  It appears that 817 is listed as "You are already subscribed and there's no need to subscribe again" in the docs.

 

 

Link to comment
31 minutes ago, Javi said:

@bmercier I am running into a couple of problems.  I  tried to use HttpURLConnection but the line "Post reuse HTTP/1.1" in the header before the first <Event>...</Event>  will throw an exception so I guess I have to stick with SSLSocketFactory (or SocketFactory for local)  for the raw output.   So my question is,  Can the URL to ISY be placed in the request header?

 


POST /isy/url_to_isy/services HTTP/1.1
Host: my.isy.io  
Content-Type: text/xml; charset=utf-8
Authorization: Basic base64UsernamePassword
Content-Length: 192
SOAPAction: urn:udi-com:device:X_Insteon_Lighting_Service:1#Subscribe

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

Making a request with the header/envelope above will return either

" HTTP/1.1 500 Internal Server Error" "Invalid response header received from ISY"

on the first request, then

"HTTP/1.1 817 unknown" "<?xml version="1.0" encoding="UTF-8"?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body><UDIDefaultResponse><status>817</status><info>n/a</info></UDIDefaultResponse></s:Body></s:Envelope>"

on subsequent requests.  It appears that 817 is listed as "You are already subscribed and there's no need to subscribe again" in the docs.

 

 

To answer your first question, I don't think passing the isyKey in a header would help, you would still have a POST reuse in the response.

I checked your payload, and I noticed a few differences with the one the admin console uses.

Use this soapaction header (Notice the ", I believe this is the cause of the problem):

Soapaction "urn:udi-com:service:X_Insteon_Lighting_Service:1#Subscribe"

And here's a body you should use (I noticed you have a malformed  /reportURL tag :

<s:Envelope><s:Body><u:Subscribe xmlns:u="urn:udi-com:service:X_Insteon_Lighting_Service:1"><reportURL>REUSE_SOCKET</reportURL><duration>infinite</duration><send>F</send></u:Subscribe></s:Body></s:Envelope>

Benoit

Link to comment
30 minutes ago, bmercier said:

To answer your first question, I don't think passing the isyKey in a header would help, you would still have a POST reuse in the response.

I checked your payload, and I noticed a few differences with the one the admin console uses.

Use this soapaction header (Notice the ", I believe this is the cause of the problem):


Soapaction "urn:udi-com:service:X_Insteon_Lighting_Service:1#Subscribe"

And here's a body you should use (I noticed you have a malformed  /reportURL tag :


<s:Envelope><s:Body><u:Subscribe xmlns:u="urn:udi-com:service:X_Insteon_Lighting_Service:1"><reportURL>REUSE_SOCKET</reportURL><duration>infinite</duration><send>F</send></u:Subscribe></s:Body></s:Envelope>

Benoit

Thanks!  I have spent too much time on this issue, funny how my.isy.io worked but when adding the isyKey it would fail.

 

The malformed /reportURL must have been a copy paste error.  Fixing the SOAPAction worked! 

Passing the isyKey in the Header also works.    

 

Link to comment
  • 2 months later...
On 4/8/2020 at 8:22 PM, bmercier said:

I tested it and can't reproduce this problem.

Are you sure you are using the URL to ISY as taken from the ISY information dialog? Are you using the admin console, or something else? Please provide more information on the SOAP call you are trying.

Just an FYI, you can do SOAP request WITHOUT having the ISY code in the URL. In this case, it will use the preferred ISY. If the preferred ISY is not set, it would indeed give you such an error message.

But if the ISY code is in the URL, this is what will be used to identify the destination ISY.

Hey @bmercier I too am trying to subscribe to my ISY through the portal via SOAP. I can get the SOAP subscription working locally no problem with the following:

var auth = 'Basic ' + new Buffer('isyUserName:isyPassword').toString('base64');
  var body = '<s:Envelope><s:Body>\
    <u:Subscribe xmlns:u="urn:udicom:service:X_Insteon_Lighting_Service:1">\
    <reportURL>REUSE_SOCKET</reportURL><duration>infinite</duration></u:Subscribe>\
    </s:Body></s:Envelope>';

  isyClient.write('POST /services HTTP/1.1\r\n');
  isyClient.write('Host: 192.168.1.23:80\r\n');
  isyClient.write('Authorization: ' + auth + '\r\n');
  isyClient.write('SOAPACTION: urn:udi-com:service:X_Insteon_Lighting_Service:1#Subscribe\r\n');
  isyClient.write('Content-Length: ' + body.length + '\r\n');
  isyClient.write('Content-Type: text/xml; charset="utf-8"\r\n\r\n');
  isyClient.write(body);
  isyClient.write('\r\n');

But when I try to connect through the portal without the ISY code as you mention I get an error 401 ok. Here's what my code looks like when doing so:

var auth = 'Basic ' + new Buffer('myPortalEmail@email.com:myPortalPassword').toString('base64');
  var body = '<s:Envelope><s:Body>\
    <u:Subscribe xmlns:u="urn:udicom:service:X_Insteon_Lighting_Service:1">\
    <reportURL>REUSE_SOCKET</reportURL><duration>infinite</duration></u:Subscribe>\
    </s:Body></s:Envelope>';

  isyClient.write('POST /services HTTP/1.1\r\n');
  isyClient.write('Host: https://my.isy.io:443\r\n');
  isyClient.write('Authorization: ' + auth + '\r\n');
  isyClient.write('SOAPACTION: urn:udi-com:service:X_Insteon_Lighting_Service:1#Subscribe\r\n');
  isyClient.write('Content-Length: ' + body.length + '\r\n');
  isyClient.write('Content-Type: text/xml; charset="utf-8"\r\n\r\n');
  isyClient.write(body);
  isyClient.write('\r\n');

I'm sure my credentials are correct, do you happen to see anything that may be causing this issue?

Thanks!

Link to comment
17 hours ago, briantreese said:

Hey @bmercier I too am trying to subscribe to my ISY through the portal via SOAP. I can get the SOAP subscription working locally no problem with the following:


var auth = 'Basic ' + new Buffer('isyUserName:isyPassword').toString('base64');
  var body = '<s:Envelope><s:Body>\
    <u:Subscribe xmlns:u="urn:udicom:service:X_Insteon_Lighting_Service:1">\
    <reportURL>REUSE_SOCKET</reportURL><duration>infinite</duration></u:Subscribe>\
    </s:Body></s:Envelope>';

  isyClient.write('POST /services HTTP/1.1\r\n');
  isyClient.write('Host: 192.168.1.23:80\r\n');
  isyClient.write('Authorization: ' + auth + '\r\n');
  isyClient.write('SOAPACTION: urn:udi-com:service:X_Insteon_Lighting_Service:1#Subscribe\r\n');
  isyClient.write('Content-Length: ' + body.length + '\r\n');
  isyClient.write('Content-Type: text/xml; charset="utf-8"\r\n\r\n');
  isyClient.write(body);
  isyClient.write('\r\n');

But when I try to connect through the portal without the ISY code as you mention I get an error 401 ok. Here's what my code looks like when doing so:


var auth = 'Basic ' + new Buffer('myPortalEmail@email.com:myPortalPassword').toString('base64');
  var body = '<s:Envelope><s:Body>\
    <u:Subscribe xmlns:u="urn:udicom:service:X_Insteon_Lighting_Service:1">\
    <reportURL>REUSE_SOCKET</reportURL><duration>infinite</duration></u:Subscribe>\
    </s:Body></s:Envelope>';

  isyClient.write('POST /services HTTP/1.1\r\n');
  isyClient.write('Host: https://my.isy.io:443\r\n');
  isyClient.write('Authorization: ' + auth + '\r\n');
  isyClient.write('SOAPACTION: urn:udi-com:service:X_Insteon_Lighting_Service:1#Subscribe\r\n');
  isyClient.write('Content-Length: ' + body.length + '\r\n');
  isyClient.write('Content-Type: text/xml; charset="utf-8"\r\n\r\n');
  isyClient.write(body);
  isyClient.write('\r\n');

I'm sure my credentials are correct, do you happen to see anything that may be causing this issue?

Thanks!

What's the response body? It's likely to have more information pointing to the problem.

Benoit

Link to comment

Hey @bmercier and @Javi thank you both for the help! It looks like a simple post to the wsdl returns a 500 error when trying to use the portal with the full url to the isy:

const postBody = `
    <s:Envelope>
        <s:Body>
            <u:Subscribe xmlns="urn:udicom:service:X_Insteon_Lighting_Service:1">
                <reportURL>REUSE_SOCKET</reportURL>
                <duration>Infinite</duration>
            </u:Subscribe>
        </s:Body>
    </s:Envelope>`;

let headers = new HttpHeaders();
headers = headers.append('Authorization', 'Basic ' + btoa(`myportalemail@email.com:myportalpassword`));
headers = headers.append('Content-type', 'text/xml');
headers = headers.append('SOAPACTION', '"urn:udi-com:service:X_Insteon_Lighting_Service:1#Subscribe"');
this.http.post('https://my.isy.io/isy/ISYKEYHERE/services.wsdl', postBody, {
  headers: headers, responseType: 'text'}).subscribe(res => {
  console.log('Component - res:', res);
});

Returns:

ERROR 
HttpErrorResponse {headers: HttpHeaders, status: 500, statusText: "Internal Server Error", url: "https://my.isy.io/isy/ISYKEY/services.wsdl", ok: false, …}
headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
status: 500
statusText: "Internal Server Error"
url: "https://my.isy.io/isy/ISYKEY/services.wsdl"
ok: false
name: "HttpErrorResponse"
message: "Http failure response for https://my.isy.io/isy/ISYKEY/services.wsdl: 500 Internal Server Error"
error: "Internal Server Error"

This works locally so I'm sure I'm missing something very basic.

Also, It looks like as mentioned above that you shouldn't need to include the url to the ISY when using the portal because the default behavior is to use the preferred isy, is this true?

Thanks so much! 

Link to comment
4 minutes ago, briantreese said:

Hey @bmercier and @Javi thank you both for the help! It looks like a simple post to the wsdl returns a 500 error when trying to use the portal with the full url to the isy:


const postBody = `
    <s:Envelope>
        <s:Body>
            <u:Subscribe xmlns="urn:udicom:service:X_Insteon_Lighting_Service:1">
                <reportURL>REUSE_SOCKET</reportURL>
                <duration>Infinite</duration>
            </u:Subscribe>
        </s:Body>
    </s:Envelope>`;

let headers = new HttpHeaders();
headers = headers.append('Authorization', 'Basic ' + btoa(`myportalemail@email.com:myportalpassword`));
headers = headers.append('Content-type', 'text/xml');
headers = headers.append('SOAPACTION', '"urn:udi-com:service:X_Insteon_Lighting_Service:1#Subscribe"');
this.http.post('https://my.isy.io/isy/ISYKEYHERE/services.wsdl', postBody, {
  headers: headers, responseType: 'text'}).subscribe(res => {
  console.log('Component - res:', res);
});

Returns:


ERROR 
HttpErrorResponse {headers: HttpHeaders, status: 500, statusText: "Internal Server Error", url: "https://my.isy.io/isy/ISYKEY/services.wsdl", ok: false, …}
headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
status: 500
statusText: "Internal Server Error"
url: "https://my.isy.io/isy/ISYKEY/services.wsdl"
ok: false
name: "HttpErrorResponse"
message: "Http failure response for https://my.isy.io/isy/ISYKEY/services.wsdl: 500 Internal Server Error"
error: "Internal Server Error"

This works locally so I'm sure I'm missing something very basic.

Also, It looks like as mentioned above that you shouldn't need to include the url to the ISY when using the portal because the default behavior is to use the preferred isy, is this true?

Thanks so much! 

Try .../services (without the .wsdl)

Link to comment

Thanks @bmercier, looks like it results in the same, a 500 error. I must be missing something else pretty basic. I'll have to keep tweaking things.

Just to double check, you mention above...

Quote

Just an FYI, you can do SOAP request WITHOUT having the ISY code in the URL. In this case, it will use the preferred ISY. If the preferred ISY is not set, it would indeed give you such an error message.

This means that I shouldn't need to include "/isy/ISYKEY" in the url right?

Thanks again!

Link to comment
1 hour ago, briantreese said:

Thanks @bmercier, looks like it results in the same, a 500 error. I must be missing something else pretty basic. I'll have to keep tweaking things.

Just to double check, you mention above...

This means that I shouldn't need to include "/isy/ISYKEY" in the url right?

Thanks again!

Exactly

Link to comment
1 hour ago, briantreese said:

Hey @bmercier and @Javi thank you both for the help! It looks like a simple post to the wsdl returns a 500 error when trying to use the portal with the full url to the isy:


const postBody = `
    <s:Envelope>
        <s:Body>
            <u:Subscribe xmlns="urn:udicom:service:X_Insteon_Lighting_Service:1">
                <reportURL>REUSE_SOCKET</reportURL>
                <duration>Infinite</duration>
            </u:Subscribe>
        </s:Body>
    </s:Envelope>`;

let headers = new HttpHeaders();
headers = headers.append('Authorization', 'Basic ' + btoa(`myportalemail@email.com:myportalpassword`));
headers = headers.append('Content-type', 'text/xml');
headers = headers.append('SOAPACTION', '"urn:udi-com:service:X_Insteon_Lighting_Service:1#Subscribe"');
this.http.post('https://my.isy.io/isy/ISYKEYHERE/services.wsdl', postBody, {
  headers: headers, responseType: 'text'}).subscribe(res => {
  console.log('Component - res:', res);
});

Returns:


ERROR 
HttpErrorResponse {headers: HttpHeaders, status: 500, statusText: "Internal Server Error", url: "https://my.isy.io/isy/ISYKEY/services.wsdl", ok: false, …}
headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
status: 500
statusText: "Internal Server Error"
url: "https://my.isy.io/isy/ISYKEY/services.wsdl"
ok: false
name: "HttpErrorResponse"
message: "Http failure response for https://my.isy.io/isy/ISYKEY/services.wsdl: 500 Internal Server Error"
error: "Internal Server Error"

This works locally so I'm sure I'm missing something very basic.

Also, It looks like as mentioned above that you shouldn't need to include the url to the ISY when using the portal because the default behavior is to use the preferred isy, is this true?

Thanks so much! 

Please pm me your uuid, will check the logs.

Benoit

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...