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
local ua = require("opcua.api")
local config = {
endpoints = {
{
endpointUrl = "opc.http://localhost:9357/opcua",
},
{
endpointUrl = "opc.https://localhost:9357/opcua",
},
{
endpointUrl = "http://localhost:9357/opcua",
},
{
endpointUrl = "https://localhost:9357/opcua",
},
},
securePolicies = {
{ -- #1
securityPolicyUri = ua.SecurityPolicy.None,
},
}
}
local server = ua.newServer(config)
server:initialize()
server:run()
local onRequest = server:createHttpDirectory()
--[[
The onRequest function shoulbe called at LSP page when a HTTP request is received.
The function is called with two arguments, the request and the response.
<?lsp
server:onRequest(request, response)
?>
]]
server:shutdown()