James Peterson Posted April 10, 2016 Share Posted April 10, 2016 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(); } Link to comment
Michel Kohanim Posted April 10, 2016 Share Posted April 10, 2016 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 Link to comment
James Peterson Posted April 10, 2016 Author Share Posted April 10, 2016 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. Link to comment
Michel Kohanim Posted April 10, 2016 Share Posted April 10, 2016 Hi James, thank you and good to hear! With kind regards, Michel Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.