============== HTTP Transport ============== OPC UA clients and servers can communicate over HTTP, which is helpful for scenarios where firewalls only allow HTTP traffic. The OPC UA specification supports binary encoding over HTTP, known as the "OPC UA Binary Protocol," which is the most efficient way to communicate between clients and servers. Additionally, this SDK supports JSON encoding over HTTP. HTTP Client =========== To connect to a server over HTTP, you need to create a client object and call the ``connect`` method. The connect method accepts the following parameters: * **endpointUrl** - The URL of the server. Servers support two kinds of schemes for HTTP endpoints. * **opc.http://host:port/path** * **opc.https://host:port/path** Some servers may also support HTTP/HTTPS schemes: * **http://host:port/path** * **https://host:port/path** * **transportProfile** - The transport profile to use can be one of the following: * **ua.TranportProfileUri.HttpsJson** expands to string *http://opcfoundation.org/UA-Profile/Transport/https-json* * **ua.TranportProfileUri.HttpsBinary** expands to string *http://opcfoundation.org/UA-Profile/Transport/https-uabinary* This parameter is optional. If not provided, the client will try to connect using binary encoding. HTTP Examples ------------- Binary Encoding ~~~~~~~~~~~~~~~ The following example shows how to connect to a server using binary encoding over HTTP. .. literalinclude:: examples/client/client_connect_http_binary.lua :language: lua :lines: 16-22 `Full source <_static/client/client_connect_http_binary.lua>`__ You can also omit the second parameter; the client will try to connect using binary encoding. .. literalinclude:: examples/client/client_connect_https_binary_default.lua :language: lua :lines: 16-22 To connect to a server over HTTPS, you need to pass URL with `opc.https://` scheme. .. literalinclude:: examples/client/client_connect_https_binary.lua :language: lua :lines: 16-22 `Full source <_static/client/client_connect_https_binary.lua>`__ JSON Encoding ~~~~~~~~~~~~~ JSON encoding is a non-standard way to communicate between OPCUA clients and servers. Because of this, you can only connect to RealTimeLogic server using JSON encoding. The following example shows how to connect to a server using JSON encoding over HTTP. .. literalinclude:: examples/client/client_connect_https_json.lua :language: lua :lines: 16-22 `Full source <_static/client/client_connect_https_json.lua>`__ HTTP Server =========== To enable HTTP transport, you need to configure the server and add the corresponding endpoint URL. You don't need to specify JSON or Binary encoding; the server will automatically detect it using the MIME type of HTTP request. Currently, the server supports only the secure policy "None" for OPC UA messages over HTTP. Security in this case is provided by HTTPS. If you choose to use HTTP, be aware that messages are not encrypted or signed. Example ------- .. literalinclude:: examples/server/server_http.lua :language: lua `Full source <_static/server/server_http.lua>`__