I have fiddler running as a reverse proxy with this command in the rules:
if (oSession.host.toLowerCase() == "108.51.116.101:8888") oSession.host = "108.51.116.101:1178";
I have fiddler running on port 8888. I also have it sending a response to cross posts:
oSession.oResponse.headers.Add("Access-Control-Allow-Origin", "*");
I keep getting 405 http errors with this javascript code in my web page on the network:
(which I sort of copied and modified from the GPS ox{x} code sample of Ryan's)
I have filled out all the vars that are shown like in the GPS code.
var device = $.ajax({
url: inControlServer + ":" + inControlPort + '/zwave/activateScenePost',
crossDomain: true,
type: 'POST',
dataType: 'json',
data: JSON.stringify({password:inControlPassword,sceneName:sceneName,activate:"1"}),
headers: {'Content-Type': 'application/json;charset=utf-8'}
},
function onSuccess(body, textStatus, response){
//console.log("Sucess:" + textStatus + ":" + body);
},
function onError(textStatus, response){
//console.log("onError:" + textStatus + ":");
});
The command is getting to the server and yielding 405s.
Thanks for any help,
Mike D.
Trying to make calls to Incontrol server from a web page
- 267 Views
- Last Post 22 February 2014
I have fiddler running as a reverse proxy with this command in the rules:
if (oSession.host.toLowerCase() == "108.51.116.101:8888") oSession.host = "108.51.116.101:1178";
I have fiddler running on port 8888. I also have it sending a response to cross posts:
oSession.oResponse.headers.Add("Access-Control-Allow-Origin", "*");
I keep getting 405 http errors with this javascript code in my web page on the network:
(which I sort of copied and modified from the GPS ox{x} code sample of Ryan's)
I have filled out all the vars that are shown like in the GPS code.
var device = $.ajax({
url: inControlServer + ":" + inControlPort + '/zwave/activateScenePost',
crossDomain: true,
type: 'POST',
dataType: 'json',
data: JSON.stringify({password:inControlPassword,sceneName:sceneName,activate:"1"}),
headers: {'Content-Type': 'application/json;charset=utf-8'}
},
function onSuccess(body, textStatus, response){
//console.log("Sucess:" + textStatus + ":" + body);
},
function onError(textStatus, response){
//console.log("onError:" + textStatus + ":");
});
The command is getting to the server and yielding 405s.
Thanks for any help,
Mike D.
Hey Mike -
Everything looks like it's in order here. It's likely related to the cross-domain, but I'm not sure. Normally those 405's are related to the wrong verb being used (GET, POST, etc.), so it's not making much sense since that's the one you actually have. If you want, you might try running InControl through your reverse proxy to copy the commands. It'll require a bit of a trick to make it work though.
1) Get something that will let you view the Sql CE database in %ProgramData%/zwave. (http://sqlcetoolbox.codeplex.com/)
2) Start your InControl server by running it as a service (tools/options), then close the GUI.
3) Edit the Settings table and change the ServerBindPort to 8888. Now start up your GUI again and it'll use port 8888. Use Fiddler listening on port 8888 to forward traffic to 1178.
At this point you can observe the traffic coming from InControl. You could activate a scene and then make sure your own version of that HTTP command matches what InControl is sending.
For what it's worth, if you restart your server after changing to port 8888, it'll bind itself to port 8888, which is why you had the server running before making the port change.
I've been working on this for four days or about 45 hours so far. I am not a web programmer. I am now getting the json parms through but fiddler shows:
'The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'.
I am using the following client javascript on my web page:
var device = $.ajax({
url: inControlServer + ":" + inControlPort + '/zwave/activateScenePost',
crossDomain: true,
type: 'POST',
dataType: 'Json',
contentType: "application/json; charset=utf-8",
data: JSON.stringify({password:inControlPassword,sceneName:sceneName,activate:"1"}),
headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'}
},
function onSuccess(body, textStatus, response){
//console.log("Sucess:" + textStatus + ":" + body);
},
function onError(textStatus, response){
//console.log("onError:" + textStatus + ":");
});
I am now getting a 400 bad request from the InControl server according to Fiddler.
http://108.51.116.101:8888/zwave/activateScenePost 400 (Bad Request)
I tried your last suggestion but was unable to get the suggested tool to work as standalone and do not use visual studio. I used a different database tool to set the port and did not gain any insight into my problem.
Please help. I am trying a lot on my own before asking for detailed help here.
Thanks,
Mike D. in Leesburg, Va.
More info and questions.
I can see a json get get rejected by the server and it has the data in the url. The post is rejected with a 400 code and the data is in the body. The fiddler view of the rejected post shows the json password,sceneName, and active. It has the variable names and values. The values are in double quotes. It looks correct to me.
This is the latest javascript try which yeilds a result of 400:
var device = $.ajax({
url: inControlServer + ":" + inControlPort + '/zwave/activateScenePost',
crossDomain: true,
type: 'POST',
dataType: 'json',
data: JSON.stringify({password:inControlPassword,sceneName:sceneName,activate:"1"}),
headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'}
},
function onSuccess(body, textStatus, response){
//console.log("Sucess:" + textStatus + ":" + body);
},
function onError(textStatus, response){
//console.log("onError:" + textStatus + ":");
});
Please be explicit in your help. If you could call me I will be available when ever you feel like it.
Thanks,
Mike D. in Leesburg, Va 7033276569
My Chrome development tools on the sending web page say about the post:
Request URL:http://108.51.116.101:8888/zwave/activateScenePost
Request Headers CAUTION: Provisional headers are shown.
Accept:application/json, text/javascript, /; q=0.01
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Origin:null
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36
Form Dataview sourceview URL encoded
{"password":"mypassword","sceneName":"SendeGPS","activate":"1"}:
Does this help?
I tried to setup a similar test as you using Fiddler. The test that I see hit the server isn't a POST, it's an OPTIONS which I believe is because it's a cross-domain request. The server is seeing it come across as OPTIONS and it doesn't know what to do with it, hence the 405 error about the method (OPTIONS) not being allowed.
Can you tell me what you are trying to accomplish in the end? Perhaps there's another way to accomplish it.
I am trying to make a web page that I can access from anywhere that will invoke scenes on my InControl setup. It's my intent to have this page on the internet and not just a browser page on my computer. I want to use it while I am away from home.
I am trying to make a web page that I can access from anywhere that will invoke scenes on my InControl setup. It's my intent to have this page on the internet and not just a browser page on my computer. I want to use it while I am away from home.
If I provided you with a hosted website from your InControl computer, would that suit your needs? If you forwarded a port to that computer, you could access the site from the internet.
Yes,I think that would be exactly what i was looking for. I have a house control program that I wrote in C that I send messages to through a program that I invoke from activating scenes on InControl. I would like to get an interface that i could write a javascript web page to send messages to the web server that you would provide so I could have buttons to press. I don't know much about servers.
As an aside, I am not a experienced web programmer and all this XML stuff throws me for a loop. I have been programming real time microprocessors since 1978 in C and assembly. I am now retired and this is my all consuming hobby. I can do almost anything if given an example to modify to my needs.
Thanks, I appreciate your efforts.
Mike D.
What sever are you using to host the page that you've been debugging with? Another option would be to send the post from your server instead of client side java script like you do now.
I have a account on rackspace in Dallas. It's sort of unusual because I have a friend with an unrelated company who lets me use his server for free. I have no control and if I want to add a email address, for instance, I have to call him and he calls his rep and the whole thing takes four hours. I also have some experience with GoDaddy where I have some cloud disk space that I pay yearly for. I do not have a web account there but would gladly get one if you think that's what I need to do. As a matter of fact I would LIKE to get my own hosting situation so that I can do what I want when ever I want to.
If I got a hosted web page on GoDaddy could I solve my problem? What I am trying to do is get messages to my house computer C program via InControl. I want a web page with buttons that send messages to InControl, which activate scenes. The scene would have a pre-script "name.cs" which would run a C program that I wrote that sends a message to my house control program. I do it this way because I understand it and it works. The only part that I have a problem with is the getting the message from the web page to the InControl server to activate a scene. All the rest works. I do not have the ability to add server qualities to my house control C program. It's way beyond my capabilities.
I program in a text editor and compile and link with command line commands. I also wrote my web page on a text editor in HTML and a small amount of javascript. I am not big on using packages that I have to learn the quirks of instead of learning how to do it myself. I use the Microsoft free 2010 visual studio free compiler package. I do not do C++ very well and can't use plain C with the 2010 Express. I can't figure it out. I can do almost anything if I can Google it. I am 60 years old and have been called "old school." I am retired and work on this project 50 to 60 hours a week.
I would love to get my own server and install my web page on it. Then I could set it up the way I want. My friend is doing me a favor by saving me money but I am willing to spend in order to get what I want.
I am not trying to make a product out of this. This house control project has been in the works since 1998. It is solely for my wife and me to use.
I am telling you where I stand so that you won't have to drag it all out of me one question at a time.
I bought the InControl Pro edition and upgrades for life.
One question: How do I tell whether I am running the Pro edition? The InControl Gui help says something about edition 134 and free upgrades until 2064.
Thanks,
Mike D.
Could I maybe to the failing post in php instead of javascript?
If you could give me an example of how to POST the parameters password, sceneName, and activate in php I could edit it from there.
Thanks,
Mike D.
Could I maybe to the failing post in php instead of javascript?
If you could give me an example of how to POST the parameters password, sceneName, and activate in php I could edit it from there.
Thanks,
Mike D.
Sorry, I'm not familiar enough with PHP to give you a sample source. However, a quick Google showed that PHP uses "curl" commands to achieve posts to other server. With that knowledge, you may be able to refer to this guide on using CURL to activate a scene.
Alternatively, I've got the start of a Web UI that you might could host on your buddy's Rackspace server. It would require nodejs -- which is very lightweight. See this thread for details. You'd need SSH access to the Rackspace server to get nodejs installed and everything up and going. This solution doesn't provide you with an automatic way to trigger scenes, but does provide you with a webpage you could access and manually click the buttons for activation.
Ryan, could you modify the gui server on port 1178 to accept the options data that my sceneName javascript post sends so I could use my javascript code? The server is giving a 405 when it gets the data but all it needs is there (password, sceneName, activate) . I really only need the activatescenepost to work to get what I want.
Thanks for the help so far,
Mike D.
Ryan, could you modify the gui server on port 1178 to accept the options data that my sceneName javascript post sends so I could use my javascript code? The server is giving a 405 when it gets the data but all it needs is there (password, sceneName, activate) . I really only need the activatescenepost to work to get what I want.
Thanks for the help so far,
Mike D.
I can certainly look into it. Would you go add this as a feature request to the portal?
I am now trying to use a HTML Form to post the data in json wrapped format.
I have this:
I need the field name for the json wrapped data. Can you tell me this?
Thanks,
Mike D.
Ryan, could you modify the gui server on port 1178 to accept the options data that my sceneName javascript post sends so I could use my javascript code? The server is giving a 405 when it gets the data but all it needs is there (password, sceneName, activate) . I really only need the activatescenepost to work to get what I want.
Thanks for the help so far,
Mike D.
I can certainly look into it. Would you go add this as a feature request to the portal?
Please check this in the latest RC build.
Thanks, I appreciate your fast response. I solved my POSTing problem by using .php on my web page server site. I sure learned a real lot in the last three weeks. Now I can turn lights on and off and open/close my garage door from my web page. I couldn't be happier. My wife is a programmer too (database stuff that I don't understand) and she understands the happiness I am experiencing.
Mike D.