Script running issue

Issue with script:

We are facing error while running a script.

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 24, in IOError: Connection refused: connect

script :

endPoint = system.tag.read("[default]/My Tags/API_endPoint").value

authEndPoint = endPoint + "abcd"
credDict = {
"Username":"abcd",
"Password":"abcd"
}

jsonCred = system.util.jsonEncode(credDict)
jsonAutenthicationResponse = system.net.httpPost(authEndPoint,"application/json",jsonCred,10000,60000,"","",{},0,1)
dictionary = system.util.jsonDecode(jsonAutenthicationResponse)

token = str(dictionary["token"])
tPath = "[default]/My Tags/token"
system.tag.writeBlocking([tPath],[token])

That is purely a network error. Your endpoint URL is not valid, or is blocking access from your system.

4 Likes

Thanks for reply. But end point url is working fine from script console. here in the above code i have put few things abcd instead of orignal content which am using here.
so ignore abcd is just to replace the orignal thing for public forum only.
authEndPoint = endPoint + "abcd"
credDict = {
"Username":"abcd",
"Password":"abcd"

i would like to know what are the different possibility i can check in gateway configurations.

endPoint = system.tag.read("[default]/My Tags/API_endPoint").value

Shouldn't this be system.tag.readBlocking()?

Cannot say this is causing the error but I did notice that.

System.tag.read is deprecated, but it still works. For this reason, I don't believe that this has anything to do with the problem, but nevertheless, you are correct; this should be updated to use system.tag.readblocking.

2 Likes

readblocking or read is not the issue. this is something else

I believe the script console executes from the PC running the Designer, while the actual script is (I'm guessing, considering the situation) running on the gateway. So if it's connecting from your PC but not from the gateway, it could be that something like a firewall is blocking communication out from your gateway.

4 Likes

You didn't state where the script is executesd that causes the error. My guess is that it's running from the gateway scope and that the user the gateway service is running under does not have sufficient privileges.

EDIT: @Felipe_CRM is on the same track. :wink:

3 Likes

YES.it is firewall issue i tried to run the script from actual pc from script console where ignition is installed it is giving issue there as well. so atleast now i know what is the issue. Thanks everyone for your help.

3 Likes

Thanks everyone. Just for info - Issue resolved it was firewall issue defined the actual port in web server settings and open the port for traffic and it's working now.

1 Like