Post error

one of my users asked me to access ignition by port 80, but i have it on the default port.
so i made a port forwarding on the server external firewall, and now i have this situation:
ext 8088 goes to 8088 (for all users)
ext 80 goes to 8088 too (for him)
it’s not a best practice, i know, anyway:
designer and clients go right when opened on the 8088.
when opened on the 80 i get an exception on the client when it launches the first sql query (the query is correct and tested):

Error executing system.db.runScalarQuery(…)
caused by Exception: Error executing system.db.runScalarQuery(…)
caused by GatewayException: Connection reset
caused by SocketException: Connection reset

the entire exception:

[code]Traceback (most recent call last):
File “event:actionPerformed”, line 17, in
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:322)
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runScalarQuery(AbstractDBUtilities.java:316)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

java.lang.Exception: java.lang.Exception: Error executing system.db.runScalarQuery(SELECT ETC (removed) ETC, , )
at org.python.core.PyException.fillInStackTrace(PyException.java:70)
at java.lang.Throwable.(Throwable.java:181)
at java.lang.Exception.(Unknown Source)
at java.lang.RuntimeException.(Unknown Source)
at org.python.core.PyException.(PyException.java:46)
at org.python.core.PyException.(PyException.java:43)
at org.python.core.Py.JavaError(Py.java:481)
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:322)
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runScalarQuery(AbstractDBUtilities.java:316)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:186)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.call(ScriptManager.java:455)
at org.python.core.PyObject.call(PyObject.java:387)
at org.python.core.PyObject.call(PyObject.java:391)
at org.python.pycode._pyx4.f$0(event:actionPerformed:26)
at org.python.pycode._pyx4.call_function(event:actionPerformed)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:539)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:155)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:266)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
at $Proxy13.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.Exception: Error executing system.db.runScalarQuery(SELECT ETC (removed) ETC, , )
… 56 more
Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Connection reset
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(GatewayInterface.java:312)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.getResponse(GatewayInterface.java:450)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:248)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:243)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.runLimitQuery(GatewayInterface.java:698)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.runQuery(GatewayInterface.java:657)
at com.inductiveautomation.ignition.client.script.ClientDBUtilities._runQuery(ClientDBUtilities.java:148)
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runScalarQuery(AbstractDBUtilities.java:309)
… 54 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.getResponse(GatewayInterface.java:374)
… 60 more

Ignition v7.5.3 (b1163)
Java: Sun Microsystems Inc. 1.6.0_33
[/code]

can i solve with a better forwarding policy or by a better configuration?
thank you

My suggestion would be an HTTP redirect, assuming that your user is still allowed access to port 8088, but just doesn’t want to have to type it in.

Setup a separate webserver on port 80 that issues a 302 to redirect to the ignition address.

I’ve messed with port forwarding and whilst I did manage to get it to work, it can be somewhat fragile. I think the gateway constructs a URL for the clients to use, and sometimes the forwarding confuses it so it ends up issuing a URL which only works internally.

i got working on that. it’s a clean and easy way to get things working, thanks for the advice.
why a 302 and not a Permanent 301 redirect?

It depends how you want the URL to be interpreted.

301 means ‘this resource used to live here, but now it lives over there’.
302 means ‘this resource is accessible here, but you need to get it from over there.’

In this case, you are declaring a shortcut. That shortcut is a valid way to access the resource so a 302 would be preferable. If you use a permanent redirect most (some? all?) browsers will update their bookmarks automatically, as the old URL is deemed to be invalid.

Say you have ignition.example.com, which won’t change even if the server or port changes.

i tried both 301 and 302, but i have a very very strange error:
the connection to the gateway is now direct:
ext 80 -> 80 (Ignition port)
ext 443 -> 443 (Ignition ssl port)

if i execute a query in the designer (and also in the client) like this:
SELECT Homepage, IF(COUNT(Homepage)=0,‘Pannello’,Homepage) FROM users WHERE Username = ‘x’
i get no errors, but on
SELECT IF(COUNT(Homepage)=0,‘Pannello’,Homepage) FROM users WHERE Username = ‘x’
i get the post error:
GatewayException: Post Error, error code = 403
why?!?!
thank you

That sounds very strange. Does it work right if you set everything back to normal?

If you write two similar queries from scratch do they also work/break respectively? My only thought at the moment is that there might be some strange query-specific connection address caching, but even that sounds really silly.

any query with the IF(COUNT(…)=0,) structure break on designer and on client.
i’m solving with a side action: i’m changing queries, using the fallback value instead of the COUNT()=0 system…
ugly solution, but works. “silly” is not enough for this situation! :open_mouth:
thank you systemparadox

It would be nice to try and track down this error a bit more.

If you set all of the ports back to normal, does it work as expected?

I’ve never seen IF and COUNT used like that before, but I made up a test and it seems to work on my setup.

Can you get us a full stack trace of that “403” error? Also, to confirm, your DB is on a different machine than the Ignition gateway is on, but is on the same local network as the Ignition machine, is that correct?

no, my DB is on the same machine.
as said, i solved changing query structure…

anyway the port changing produced a new error, as explained here viewtopic.php?f=72&t=6581&p=30198#p30198