about opc ua badsecurechannelclosed - opc-ua

I have two OPC UA servers. One is implemented in Java and the other is implemented in Python. It is normal to connect to the Java OPC UA server with opcuahalper. The same code links to the python server and reports an error badsecurechannelclosed. Are there any friends who encounter this problem? How did you solve it
code below:
// select the best endpoint.
EndpointDescription endpointDescription = CoreClientUtils.SelectEndpoint( serverUrl, UseSecurity );
EndpointConfiguration endpointConfiguration = EndpointConfiguration.Create( m_configuration );
ConfiguredEndpoint endpoint = new ConfiguredEndpoint( null, endpointDescription, endpointConfiguration );
m_session = await Session.Create(
m_configuration,
endpoint,
false,
false,
(string.IsNullOrEmpty( OpcUaName )) ? m_configuration.ApplicationName : OpcUaName,
60000,
UserIdentity,
new string[] { } );

Related

Snapshot return array

I've created a web socket server with Node.js to connect two Flutter apps. I can post a message to server but when I listen to it on WebApp i receive an array [79,101] instead message (Oi). How can I solve it?
Sink Message
void _sendMessage(data) {
widget.channel.sink.add('Oi');
}
Cliente Stream Builder
StreamBuilder(
stream: channel.stream,
builder: (context, snapshot) {
return Text(snapshot.hasData ? '${snapshot.data}' : 'Null');
},
)
Node.js Server
const WebSocket = require('ws');
// start the server and specify the port number
const port = 8080;
const wss = new WebSocket.Server({ port: port });
console.log(`[WebSocket] Starting WebSocket server on localhost:${port}`);
wss.on('connection', (ws, request) => {
const clientIp = request.sock.remoteAddress;
console.log(`[WebSocket] Client with IP ${clientIp} has connected`);
ws.send('Connected!');
// Broadcast aka send messages to all connected clients
ws.on('message', (message) => {
wss.clients.forEach((client) => {
if (client.readyState === WebSocket.OPEN) {
client.send(message); } })
console.log(`[WebSocket] Message ${message} was received`); });
});
This might not be the solution you are looking for but I would try and convert the response via String.fromCharCodesince the response might be ASCII characters to begin my way of debugging.

Creating LSP (Language Server Protocol) for multiple clients using RPC

I am trying to create a custom LSP.
My goal is to create one language server for both monaco editor (on web) and vscode extension.
Currently I use Node/IPC to connect the vscode-extension with the server.
and ws-jsonrpc to connect monaco editor with the server.
quoting from this article Extending a client with the language server protocol
:
There are multiple ways to use JSON-RPC, but you see these two ways in
most implementations:
Communication is done via the standard input / output, i.e., the command line interface
Communication is performed via TCP/IP, i.e., network messages similar to HTTP
I should be able to use JSON-RPC for both communication (internal communication between processes which is the vscode-extesion in my case , and external communication which is monaco-editor in my case)
Here is how I am launching the server for the moment:
For IPC communication:
const languageServer = new LanguageServer(createConnection(ProposedFeatures.all));
languageServer.start();
For WebSocket RPC:
import * as express from "express";
import * as ws from "ws";
import * as rpc from "vscode-ws-jsonrpc";
import * as url from "url";
import * as http from "http";
import * as net from "net";
const app = express();
const server = app.listen(3000);
const wss = new ws.Server({
noServer: true,
perMessageDeflate: false
});
function launch(socket : rpc.IWebSocket ){
const reader = new rpc.WebSocketMessageReader(socket);
const writer = new rpc.WebSocketMessageWriter(socket);
const languageServer = new LanguageServer(createConnection(reader, writer));
languageServer.start();
}
server.on('upgrade', (request: http.IncomingMessage, socket: net.Socket, head: Buffer) => {
const pathname = request.url ? url.parse(request.url).pathname : undefined;
console.log("server on upgrade ", pathname);
if (pathname === '/sampleServer') {
wss.handleUpgrade(request, socket, head, (webSocket: any) => {
const socket: rpc.IWebSocket = {
send: (content: any) => webSocket.send(content, (error: any) => {
if (error) {
throw error;
}
}),
onMessage: (cb: any) => webSocket.on('message', cb),
onError: (cb: any) => webSocket.on('error', cb),
onClose: (cb: any) => webSocket.on('close', cb),
dispose: () => webSocket.close()
};
// launch the server when the web socket is opened
if (webSocket.readyState === webSocket.OPEN) {
launch(socket);
} else {
webSocket.on('open', () => {
launch(socket);
});
}
});
}
})
The server that you are using should not operate with multiple clients using it at the same time. It even says: "the protocol currently assumes that one server serves one tool.". Also, maybe read this article about your topic. **https://code.visualstudio.com/api/language-extensions/language-server-extension-guide **

Why am I getting an Grpc.Core.RpcException when trying to get data from gRPC service written .net core

I have a gRPC service (written in .net core 3.1) deployed in windows server as a self hosted service running in kerstel.
I added the below configuration to get the service running in https.
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http2"
},
"Endpoints": {
"HttpsInlineCertFile": {
"Url": "https://hostname:8081",
"Protocols": "Http2",
"Certificate": {
"Path": "path to .pfx file",
"Password": "Super secret password"
}
}
}
Using the below code
using GrpcChannel channel = GrpcChannel.ForAddress(httpsHost);
var client = new MyClient(channel);
var response = client.GetEntity(RequestCreator.GetRequest());
Console.WriteLine("Recieved: " + response.ToString());
I get the an below exception and the inner exception is null.
Status(StatusCode=Internal, Detail="Error starting gRPC call: The SSL connection could not be established, see inner exception.")
Is there anything I should be adding to get the client to get the data from the service?
Thanks in advance
Sorry for the late response to my question. The proble was the proxy. What I ended up doing is create a webproxy, add the gRPC service url to the bypassArrayList, create httpClientHandler, assigned the created proyx then create a httpClient that uses that httpClientHandler.
var proxy = new WebProxy
{
Address = new Uri(proxyServer),
UseDefaultCredentials = true,
BypassProxyOnLocal = true,
Credentials = CredentialCache.DefaultNetworkCredentials
};
proxy.BypassArrayList.Add(serviceUrl);
var httpClientHandler = new HttpClientHandler
{
Proxy = proxy,
DefaultProxyCredentials = CredentialCache.DefaultNetworkCredentials,
UseDefaultCredentials = true,
UseProxy = true,
};
var client = new HttpClient(httpClientHandler)
{
DefaultRequestVersion = HttpVersion.Version20
};
using var channel = GrpcChannel.ForAddress(serviceUrl, new GrpcChannelOptions
{
HttpClient = client
});

RESTful Chromless implementation

I am looking for a way to use headless chrome similar to what chromeless does but instead of being implemented as a nodejs endpoint, allowing restful requests with the html content as a payload.
I want to run this service on aws lambda being triggered through API Gateway. Does anyone have experience with this usecase?
There's nothing keeping you from using Chromeless in your use-case. Chromeless can be used within an AWS Lambda function. You can take a (RESTful) request coming from AWS API Gateway and then do something with it and Chromeless. You can combine the #serverless-chrome/lambda package with Chromeless to get headless Chrome running within Lambda so that Chrome is available to Chromeless. The Chromeless Proxy works in a similar way. For example, your Lambda function's code might look like (this is untested code I just cobbled together, but should convey the idea):
const launchChrome = require('#serverless-chrome/lambda')
const Chromeless = require('chromeless').Chromeless
module.exports.handler = function handler (event, context, callback) {
const body = JSON.parse(event.body) // event.body coming from API Gateway
const url = body.url
const evaluateJs = body.evaluateJs
launchChrome({
flags: ['--window-size=1280x1696', '--hide-scrollbars'],
})
.then((chrome) => {
// Chrome is now running on localhost:9222
const chromeless = new Chromeless({
launchChrome: false,
})
chromeless
.goto(url)
.wait('body')
.evaluate(() => `
// this will be executed in headless chrome
${evaluateJs}
`)
.then((result) => {
chromeless
.end()
.then(chrome.kill) // https://github.com/adieuadieu/serverless-chrome/issues/41#issuecomment-317989508
.then(() => {
callback(null, {
statusCode: 200,
body: JSON.stringify({ result })
})
})
})
.catch(callback)
})
.catch((error) => {
// Chrome didn't launch correctly
callback(error)
})
}
You'll find a similar thread on the Chromeless Issue tracker here.
Disclosure: I'm a collaborator/author of these packages.

ratchet with zmq on subdomain not connecting

I'm trying to run ratchet on sub domain.. i have create ratchet server as described in Ratchet push integration and uploaded it to subdomain.domain.com my subdomain is also on same server
my projects is in laravel which is on main domain.(www.domain.com)
here is my chatserver code which is on subdomain
<?php
require dirname(__DIR__) . '/vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$pusher = new MyApp\Pusher;
//Listen for the web server to make a ZeroMQ push after an ajax request
$context = new React\ZMQ\Context($loop);
$pull = $context->getSocket(ZMQ::SOCKET_PULL);
$pull->bind('tcp://subdomain.domain.com:5555'); //Binding to 27.0.0.1 means the only client that can connect is itself
$pull->on('message', array($pusher, 'onBookingSeats'));
//Set up our WebSocket server for clients wanting real-time updates
$webSock = new React\Socket\Server($loop);
$webSock->Listen(80,'0.0.0.0'); // Binding to 0.0.0.0 means remotes can connect
$webSock = new Ratchet\Server\IoServer(
new Ratchet\Http\HttpServer(
new Ratchet\WebSocket\WsServer(
new Ratchet\Wamp\WampServer(
$pusher
)
)
),
$webSock
);
$loop->run();
?>
my controller code from where i am sending request to socket which is on www.domain.com
$context = new ZMQContext();
$socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
$socket->connect("tcp://subdomain.domain.com:5555");
$socket->send(json_encode($seats));
return Redirect::to('booking/payment');
and recieving websocket request in js file on www.domain.com
var conn = new ab.Session('ws://rtime.ticketpk.com:80',
function() {
conn.subscribe('kittensCategory', function(topic, data) {
// This is where you would add the new article to the DOM (beyond the scope of this tutorial)
console.log('New article published to category "' + topic + '" : ' + data.title);
});
},
function() {
console.warn('WebSocket connection closed');
},
{'skipSubprotocolCheck': true}
);
i think i'm having problem in binding with websockets