I am trying to use URLConnection to get data from a device on my local network.
This device has a self signed certificate that is normally rejected by MacOS unless an exception is granted.
Access works in the various browsers (after granting the exception)
I have included a .plist in the root of the source code with:
which works fine in the compiled application.
The compiler automatically includes the data of my application.plist in the info.plist of the compiled app.
However how do I coerce the debugger to use this .plist as well?? Currently I cannot debug AND have URLConnection getting the data successfully.
Thanks for your quick reply. I suspected that, however, since I do not use this environment too much, I do not know where to put this .plist so the debugger loads it as well… The compilers adds it correctly during the build phase. No problem there.
Currently I have the file located next to the project file and other sources code.
Every Mac developer has to deal with this sillyness.
You make the plist file. Then you drag-and-drop the file into the navigator. That’s it. You can get fancy and do an IDE script. Which can differ in execution between debug and build. But for the file you don’t have to do anything.
Have you checked the info.plist file of the debugged app?
That’s indeed what I already did. [quote]You make the plist file. Then you drag-and-drop the file into the navigator. That’s it.[/quote]
I now checked the info.plist file of the debug version and it does contains exactly the same info as the compiled version … So it seems that all is fine at the input end. However, execution is not the same as the compiled version…
It fails on the SSL with a message that it cannot establish a safe connection. With error number -1200 in the exception and HTTPStatusCode = 4294966096 which seems a clumsy translation of the same -1200…
url.text = "https://eatonEasy.fritz.box"
api.text = "/api/get/data?elm=MB(1)"
Button pressed on window:
(MySocket is a URLConnection).
eatonEasy = new MySocket
eatonEasy.AllowCertificateValidation = false
eatonEasy.send("GET",url.text+api.text)
MySocket ContentReceived:
[code]Var result As JSONItem
Var returndata as JSONItem = nil
try
result = new JSONItem(content)
Var operands as JSONItem = result.Child(“OPERANDS”)
if operands.HasName(“MBRANGE”) then
returnData = operands.Child(“MBRANGE”)
end
if operands.HasName(“MBSINGLE”) then
returnData = operands.Child(“MBSINGLE”)
end
if operands.HasName(“AORANGE”) then
returnData = operands.Child(“AORANGE”)
end
if operands.HasName(“AIRANGE”) then
returnData = operands.Child(“AIRANGE”)
end
if operands.HasName(“IRANGE”) then
returnData = operands.Child(“IRANGE”)
end
if operands.HasName(“ORANGE”) then
returnData = operands.Child(“ORANGE”)
end
if operands.HasName(“MRANGE”) then
returnData = operands.Child(“MRANGE”)
end
Window1.TextArea1.text = “”
if returndata <> nil then
if returndata.ChildAt(0).HasName(“V”) then
Var c as string = DecodeBase64(returndata.ChildAt(0).Value(“V”))
var i as Integer
Var s as String = "Response: "
for i=0 to c.Bytes-1
s = s + str(c.Middle(i,1).asc) + " "
next
Window1.TextArea1.Text = s
else
Window1.TextArea1.Text = "No V: " + content
end
else
Window1.TextArea1.text = "No Valid data received: " + content
end
Exception err as JSONException
Window1.TextArea1.Text = err.Message
end
[/code]
No, this is just to debug it. The compiled/built version communicates fine via the SSL connection.
The debug version not. It refuses to setup the connection as if the .plist exception is not defined.
Ahum
I found the problem: I had a breakpoint activated just after the send thus before the URLConnection was able to do its job… Hence the interaction failed because the process was stuck on the breakpoint.
Putting the breakpoint where it makes sense, resolves the issue.