IOPCShutdown::Advise Failed : error 80040202 - c++

I broke my head while looking for the cause of this error (4 days)
I have an OPC DA server running in a remote machine.
The OPC DA client is located in another machine.
in the client implementation I create an external instance via CoCreateInstanceEx()
HRESULT result = ::CoCreateInstanceEx(clsid, NULL, clsctx, sinptr, 1, &mqi);
PRINT_COMERRORIF(result, "CoCreateInstanceEx failed");
and it works fine and I get a pointer to the remote OPC server (mqi.pItf)
the problem comes when I call the advise() function of IConnectionPoint interface
I specify that I found the connection point and I return a pointer to the IOPCShutdown interface (_MY_shutdown) before calling the advise function
result = server_object->QueryInterface(IID_IConnectionPointContainer
(void**)&connection_point_container);
PRINT_COMERRORIF(result, CTXID(this) "No IConnectionPointContainer interface");
result = connection_point_container->FindConnectionPoint(IID_IOPCShutdown, &_MY_shutdown);
PRINT_COMERRORIF(result, CTXID(this) "No IOPCShutdown connection point found");
result = _MY_shutdown->Advise(_MY_shutdown_callback, &_MY_shutdown_cookie); // HERE IS THE ISSUE
PRINT_COMERRORIF(result, CTXID(this) "IOPCShutdown::Advise Failed");
and I got this error:
IOPCShutdown::Advise Failed : error 80040202
I've checked the DCOM Setting for Discovery of Remote OPC Servers configuration and I did everything as described but no way ;(
Here is my configuration:
Server side
- OPC DA Server installed and running
- local user account is created
- DCOM settings are configured as required
- Policy settings are configured as well
Client side
- OPC DA client interface installed.
- local user accounts are created on the both Nodes. Accounts have the same
name and passwords like on the server.
firewall is disabled in both server/client.

Have you properly configured DCOM and policy settings on a Client side?
As mentioned in comments, because for asynchronous connections (when callback is invoked) your client behaves as a server and server - as a client.

It works when I change the authentification level of my OPC DA server in DCOM Config from "Connect" to "None", I don't know why but it works ^^

Related

Connection to Google IoT with Hive MQTT client instead of Paho

I have working code similar to this connecting to google IoT with the paho client.
Since I am in a spring boot reactive application, I would like to use Hive MQTT Client, but I can't find the right setup, I keep having the following error message :
com.hivemq.client.mqtt.exceptions.ConnectionClosedException: Server closed connection without DISCONNECT.
The current code I use :
hiveClient = MqttClient.builder()
.identifier(UUID.randomUUID().toString())
.serverHost("mqtt.googleapis.com")
.serverPort(443)
.useMqttVersion3()
.sslWithDefaultConfig()
.simpleAuth(
Mqtt3SimpleAuth.builder()
.username("unused")
.password(StandardCharsets.UTF_8.encode("// a token string generation that works fine with palo"))
.build()
)
.build()
.toBlocking();
hiveClient.connect(); // Error
It looks like the identifier (client ID) should be set to something other than a UUID. The documentation indicates the client ID should be formed as the following path:
projects/PROJECT_ID/locations/REGION/registries/REGISTRY_ID/devices/DEVICE_ID
Note that all of the requirements for the Google Cloud IoT Core MQTT device bridge are strict, so also verify that Hive is configured as follows:
Mqtt 3.1.1
TLS 1.2
Publish to /devices/DEVICE_ID/events or /devices/DEVICE_ID/state
Subscribe to /devices/DEVICE_ID/config or /devices/DEVICE_ID/commands/#
QoS 0 or 1
Note that if you do not adhere to the requirements, your device gets disconnected. Additional information on the disconnect reason may be available in the logging for your registry visible on the Cloud Console for IoT.

error when publish data to aws IoT using BG96 and MQTT protocol

I'm trying to publish my data to Amazon web services using BG96 (NB-IoT device that use AT commands)
I'm following the official documentation (Quectel)
so I configure SSL parameters ( with the command : at+ qsslcfg=...) and start MQTT SSL connection successfully (AT+QMTOPEN=...) but when I try to connect to MQTT server( AT+QMTCONN=...), the connection is closed immediately
Please help,how can I fix this problem and publish my data to Amazon web services ?
AT+QSSLCFG="ciphersuite",1,0x0035
OK
AT+QSSLCFG="sslversion",1,3
OK
AT+QSSLCFG="cacert",1,"ufs:cacert.pem"
OK
AT+QSSLCFG="clientcert",1,"ufs:clientcert.pem"
OK
AT+QSSLCFG="clientkey",1,"ufs:clientkey.pem"
OK
AT+QSSLCFG="seclevel",1,2
OK
AT+QSSLCFG="negotiatetime",1,300
OK
AT+QSSLCFG="ignorelocaltime",1,0
OK
//Configure MQTT session into SSL mode.
AT+QMTCFG=”SSL”, 0, 1, 1
//Start MQTT SSL connection
AT+QMTOPEN=0, "a2xxxxxxxxxzxx.iot.us-east-1.amazonaws.com",”8883”
OK // ok
+QMTOPEN: 0,0 // means the connction is starts succsesfully
//Connect to MQTT server
AT+QMTCONN=0,"bg96"
ok
+QMTSTAT 0,1 //but this message means that the connection is closed
I had the same problem here with BG96, MQTTS over port 8883.
My solution with this modem is to force the MQTT version to "v4", according to the AT MQTT Manual. So, after your AT+QMTCFG=”SSL”, 0, 1, 1, try using AT+QMTCFG="version",0,4, then open the connection and authenticate.
I find the solution ,
My problem is that I should create a policy to allow connection to aws and attach this policy to the thing that I create ,
If nb-iot is used then we shoud configure the DNS address to Google public DNS : 8.8.8.8 and 8.8.4.4
And of course issue all commands attentively to update certificates , configure ssl context , activate tcp context and finally open mqtt connection and connect to publish or subscribe to topic

DefaultHandshakeHandler's determineUser not called on Production Server

I have a grails project which uses Spring websockets. I have implemented the DefaultHandshakeHandler to create random principal name for each new session and use convertAndSendToUser to send messages.
Everything works fine in local run. I am also able to deploy the WAR file on an AWS EC2 Linux Instance running latest tomcat. The file deploys fine and the Connect and Disconnect events on websockets can be detected correctly.*
The only problem is, My CustomHandshakeHandler's determineUser does not get called on production. Due to this my StompHeaderAccessor's principal is always null and the code starts spitting NPEs.
This is how i have declared the CustomHandshakeHandler :
class CustomHandshakeHandler extends DefaultHandshakeHandler {
#Override
protected Principal determineUser(ServerHttpRequest request,
WebSocketHandler wsHandler,
Map<String, Object> attributes) {
// Generate principal with UUID as name
return new StompPrincipal(UUID.randomUUID().toString())
}
}
This is how i set the handshake handler configuration :
#Override
void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) {
stompEndpointRegistry.addEndpoint("/ws-ep") // Set websocket endpoint to connect to
.setHandshakeHandler(new CustomHandshakeHandler()) // Set custom handshake handler
.withSockJS() // Add Sock JS support for frontend
}
I tried deploying the same WAR file on local Tomcat 8 and it again works fine. It seems problem happens due to AWS. I also searched for some other AWS and websocket related issues. I came across some ELB compatibility related things but i Don't think that's my case since my websockets are working fine (Events are being received)
Can someone please help out or point me in right directions
Problem was with Nginx settings which upgrade the Http Request to WS request. This question helped a lot : Spring WebSocket: Handshake failed due to invalid Upgrade header: null

Presto server on AWS - Cannot connect to discovery server

Trying to run Presto coordinator server with discovery server embedded on AWS CDH4 cluster
config.properties:
coordinator=true
datasources=jmx
http-server.http.port=8000
presto-metastore.db.type=h2
presto-metastore.db.filename=var/db/MetaStore
task.max-memory=1GB
discovery-server.enabled=true
discovery.uri=http://ip-10-0-0-11:8000
When server starts it can't register itself with discovery (relevant logs):
2013-11-08T19:38:38.193+0000 WARN main Bootstrap Warning: Configuration property 'discovery.uri' is deprecated and should not be used
2013-11-08T19:38:38.968+0000 INFO main Bootstrap discovery-server.enabled false true
2013-11-08T19:38:38.975+0000 INFO main Bootstrap discovery.uri null http://ip-10-0-0-11:8000 Discovery service base URI
2013-11-08T19:38:40.916+0000 ERROR Discovery-0 io.airlift.discovery.client.CachingServiceSelector Cannot connect to discovery server for refresh (collector/general): Lookup of collector failed for http://ip-10-0-0-11:8000/v1/service/collector/general
2013-11-08T19:38:42.556+0000 ERROR Discovery-1 io.airlift.discovery.client.CachingServiceSelector Cannot connect to discovery server for refresh (presto/general): Lookup of presto failed for http://ip-10-0-0-11:8000/v1/service/presto/general
2013-11-08T19:38:43.854+0000 INFO main org.eclipse.jetty.server.AbstractConnector Started SelectChannelConnector#0.0.0.0:8000
Tried to also run standalone Discovery server, same effect. Looks that listener is started after registration attempt is made.
I was wondering if someone would notice this in the logs :) It's actually not a problem. The error appears because the discovery client starts before the discovery server is ready. You'll see "succeeded for refresh" shortly after in the logs which shows that it's working. We will fix the log message eventually but it's purely a cosmetic issue.

Can't reach wicket quickstart from outside firewall

I have a project which, for purposes of server configuration, is just a wicket quickstart archetype. I've added some application code, but haven't really done anything to change the default jetty configuration.
I can run and test my application locally using:
http://localhost:8080
or:
http://bekkar:8080 (my PC's network name)
or:
http://192.168.1.2:8080/ (my PC's local IP)
I want to access my wicket app from outside my router firewall. (I eventually will test it on my Blackberry, but for now I'm using Google Chrome to try to reach it externally.)
Using http://www.whatismyip.com/ I found my router's IP.
I use:
http://###.###.###.###:8080
and I get a screen that says Authentication Required, asking for a username and password. I don't have any kind of authentication set up in my wicket app.
I have a NetGear router, WGR614v7. Using the router admin, under port forwarding, I add the following custom service:
Service Name=wicket
Starting Port=8080
Ending Port=8080
Server IP Address=192.168.1.2 //my computer's local IP
After adding the port forwarding service definition, I get a different message from Chrome:
Oops! Google Chrome could not connect to ###.###.###.###:8080
How can I make my wicket jetty quickstart accessible from outside my router firewall? I don't know if this is a wicket/jetty issue (belonging on SO) or a firewall issue (belonging on serverfault), so I'll post it here, first.
Thanks!
First, try with just simple apache, or woof. Be sure to bind it to 0.0.0.0 (all IPs).
A) If you can't reach it, it's the router config problem.
B) If that works, you know it't jetty/wicket config.
case A) I don't know that router, but look for port forwarding. I wasn't able to get ASUS WL500gP passing requests in, so I am not the right one to advice here :)
case B) Does Jetty bind to 0.0.0.0? Can you reach it from other machine on the local network?
Not much useful answer, but I hope it helps a bit.
I run jetty/wicket apps on my system all the time and access them remotely. I don't think there is anything special that I've done with Jetty, and especially not wicket to make this work. But if it helps, here is an example Start.java file (this is from one of my apps -- not sure if it is the same as the one in quickstart, as I don't have a quickstart available right now):
public class Start {
public static void main(String[] args) throws Exception {
Server server = new Server();
SocketConnector connector = new SocketConnector();
// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(1000 * 60 * 60);
connector.setSoLingerTime(-1);
connector.setPort(8080);
server.setConnectors(new Connector[] { connector });
WebAppContext bb = new WebAppContext();
bb.setServer(server);
bb.setContextPath("/");
bb.setWar("src/main/webapp");
// START JMX SERVER
// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
// server.getContainer().addEventListener(mBeanContainer);
// mBeanContainer.start();
server.addHandler(bb);
try {
System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
server.start();
System.in.read();
System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
// while (System.in.available() == 0) {
// Thread.sleep(5000);
// }
server.stop();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(100);
}
}
}
I'm using a DLink router, so I'm not sure how to configure yours. However, you should also check your router to see if it has remote web admin turned on, and if it is on port 8080. If so, turn it off, as it might be interfering with your port forwarding.