I am using eclipse milo java OPCUA client SDK in our app for OPC implementation.
I am able to create session, subscription and monitor. It is working fine
but when opc server restarts and I try to delete previous session and create a new one with same parameters I get the below exception:
UaException: status=Bad_Timeout, message=timed out waiting for
acknowledge
The line which throws the error is:
EndpointDescription[] endpoints =
UaTcpStackClient.getEndpoints(endpointurl).get();
On server side I get the error:
OPCUAServerEndPoint#_on_client_connection The maximum number of
connection has b een reached - Connection is refused
However, when I try to create the session again with same parameters it does get created
You shouldn't be creating a session by yourself as this is handled for you by the client, and you definitely shouldn't be trying to delete the previous session.
The only thing you need to do is add a SubscriptionListener to the OpcUaSubscriptionManager and handle the onSubscriptionTransferFailed callback.
Receiving this callback means that the client has reconnected and had to create a new session, but the server was unable to transfer its old subscriptions to this session. This usually happens when either it took too long to reconnect and the subscriptions timed out or if something causes the server to lose all of its state, e.g. it gets restarted.
I've added a somewhat convoluted integration test that demonstrates that all of this does indeed work, you can see it here.
Related
I'm trying to configure the WSO2 API Manager. (version - v4.0.0)
When I try to create REST API and point to the endpoints I"m getting a Connection error message for the given endpoints. I have hosted the API Manager and the back end services on the same server(backend services are running on the tomcat application on the same server in port 8080)
API Manager Log produces the following message :
ERROR {org.wso2.carbon.apimgt.rest.api.publisher.v1.impl.ApisApiServiceImpl} - Error occurred while sending the HEAD request to the given endpoint url: org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 4000 ms
would really like to what has caused the issue.
P.S: I can access the backend services directly without any connection issues using a REST client.
It's difficult to answer the question without knowing the exact details of your deployment and the backend. But let me try. Here is what I think is happening. As you can clearly see, the error is a connection timeout The host did not accept the connection within timeout of 4000 ms.
Let me explain what happens when you click on the Check Endpoint Status button. When you click on the Check Endpoint Status button, the Browser is not directly sending a request to the Backend to validate it. The Backend URL will be passed to the APIM Server, and the Server will perform the validation by sending an HTTP HEAD request to the BE service.
So there can be two causes. First may be your backend doesn't know how to handle a HEAD request which is preventing it from accepting the request. But given the error indicated it's a network issue, I doubt it even reached the BE.
The second one is, that your Backend is not accessible from the place API Manager is running. If you are running API Manager on Server A and trying to access API Manager via browser from Server B(Local Machine). Although you can access the BE from Server B may be from Server A it's not accessible. When I say BE is not accessible from API Manager server, it means it's not accessible with the same URL that was used in API Manager. It doesn't really matter if it runs in the same Server if you are using a different DNS other than localhost to access it. So go to the server API Manager is running and send a request using the same URL that was used in API Manager and see whether it's accessible from there.
First try doing a curl request by login into the server where APIM is running (not from your local machine). Maybe due to some firewall rules within the server, the hostname given in the URL may not be accessible. Also, try sending a HEAD request as well. You might be able to get some idea why this is happening
We have a spring java app using EWS to connect to our on prem 2016 Exchange server and 'stream' pulling emails. Every 30 minutes a new 30 minute subscription is made (via new thread). We assume old connection just expires.
When one instance is running in our environment, it works perfectly fine, but when two instances run, after some time one instance will eventually start throwing error about
You have exceeded the available concurrent connections for your account. Try again once your other requests have completed.
It seems like an issue which is then hit by throttling. I found that the Exchange servers config is:
EWSMaxConcurrency=27, MaxStreamingConcurrency=10,
HangingConnectionLimit=10
Our code previously didn't explicitly close connections and unsubscribe (was running fine without when one instance). We tried including both but the issue still persists and we noticed the close method for StreamingSubscriptionConnection throws error. The team that handles the Exchange server can find errors referencing the exceeding connection count error above, but nothing relating to the close connection error
...[m.e.w.d.n.StreamingSubscriptionConnection.close(349)]: java.lang.Exception: microsoft.exchange.webservices.data.notification.StreamingSubscriptionConnection
Currently we don't have much ability to make changes on the exchange server side. I'm not familiar with SOAP messages but I was planning to look into how to monitor them to see what inbound and outbound messages there are for some insights
For the service I set service.setTraceEnabled(true) and service.setTraceFlags(EnumSet.allOf(TraceFlags.class)
However I only see trace messages in console when an email arrives. I dont see any messages during start up when a subscription/connection is created
Can anyone help provide any advice on how I can monitor these subscription related messages?
I tried using SOAPUI but I'm having difficulty applying our server's WSDL. I considered using the Tunnelij plugin for intellij but I'm not too familiar with how to set it up either
My suspicion is that there is some intermittent latency issue on Exchange server side, perhaps response messages are not coming back in a timely manner, and this may be screwing up. I presume if I monitor these SOAP messages then I should see more than 10 requests to subscribe before that error appears
The EWS Logs on the CAS (Client Access Server) should have details about the throttling issue. Are you using Impersonation in you Application if you not using Impersonation then the concurrent connections are charged against the account your using with Impersonation that get charged against the account your impersonating. The difference here is that a single user can have no more the 10 streaming subscriptions (unless you modify the web.config) if your using impersonation than you can scale your application to 1000's of users see https://github.com/MicrosoftDocs/office-developer-exchange-docs/blob/main/docs/exchange-web-services/how-to-maintain-affinity-between-group-of-subscriptions-and-mailbox-server.md
I have a working xmpp web client using strophe,my current approach is to login user from strophe on java script,but security point of view it is not secure and in my application ihave to switch pages vary rapidly,
while searching on internet on SO i found that Jake Moffitt has given a solution of implementing session which overcome both limitation ,as mention in his book "professional xmpp using java script",one can easy implement session and get SID and RID on server[have to create xmpp bosh connection from server]and pass it to java script(jid,sid and rid) which will than used in attach() method to connect with xmpp bosh manager,
I am using java as server side language,while some one try to implement boshclient in java it seem java smack and jbosh is only available solution (i mean working solution),
But i couldn't find any method by which i can get RID and SID using java script, i went through another approach
why not run strophe client on top of jvm,(why to run strophe on jvm? i am able to get rid and sid using strophe on java script as mention on this link ,why one should try this solution on java) i have included rihno in my dynamic web project js.jar to my lib folder in WebContent/WEBINF/lib and gave a qualified path to run env.rihno.js which create an browser run time on java and included strophe.js and jquey.js file and try to connect to bosh clint as i did on javascript for my web app,
code::
Context cx = ContextFactory.getGlobal().enterContext();
cx.setOptimizationLevel(-1);
cx.setLanguageVersion(Context.VERSION_1_5);
Global global = Main.getGlobal();
global.init(cx);
Main.processSource(cx, "/home/devwrat/workspace/Test/env.rhino.1.2.js");
Main.processSource(cx, "/home/devwrat/workspace/Test/jquery-1.11.1.js");
Main.processSource(cx, "/home/devwrat/workspace/Test/strophe.js");
Main.processSource(cx, "/home/devwrat/workspace/Test/boshconnection.js");
It seem everything is working fine on java until cinnection.connect() using strophe execute in my java script,i observers that it is not connection to bosh manager.
My question is as below
is it possible to establish bosh connection using strophe in java? and yes how?
thanks in advance!!!!
Edit (21-8-2014)::
I observed that after executing conn.connect(Arthur.jid, Arthur.password, function (status){print(status);}),status is 1 which in turn means connection status is connecting,it always say connecting never get connected ??May be xmpp bosh manager is not authenticating connection!!!
Strophe.js is usually used with the client side javascript. I think you're adding unnecessary complexity by trying to run Strophe.js on the server side.
You've mentioned two separate problems, moving authentication to the server side, and also maintaining session between page changes.
Problem #1 Moving authentication to server-side (Prebinding)
If you want to move the login process to the server side, then you can do so by utilizing a java based XMPP library or by manually creating and sending the stanza's (isn't that hard, it's basically just XML being sent over HTTP) which are needed for the authentication process. Once the BOSH session has been established server side, the JID+RID+SID attributes of the session can be passed to the client side javascript and used by Strophe's attach().
In order to write your own BOSH pre-binder, you should start by inspecting the stanza's which are exchanged between Strophe and ejabberd, and you should also read XEP-206. In summary, you will need to create a HTTPClient of some sort, point it towards ejabberd's /http-bind/ address, and begin sending it the same messages that strophe sends during login. You can always inspect the messages (stanzas) with your browser's network debugger, or Fiddler2 (I recommend this). Once you understand how Strophe establishes a session, you can begin writing your own server side mechanism to establish a session. Once the session has been established server side, you can extract the SID+RID+JID, and send them to your page and use them with attach().
Problem #2 Maintaining session between page changes
The second problem you state is that your application changes pages frequently. If you want to implement a mechanism to maintain your XMPP session between page changes, this can be done by utilizing strophes attach() in combination with a mechanism to store the JID+RID+SID. I use a combination of LocalStorage with fallback to AJAX to accomplish this.
BOSH and XMPP
The reason you cannot extract the RID and SID values from many XMPP libraries is because they don't use these attributes. SID and RID are used with BOSH, which is what enables us to communicate with an XMPP server using HTTP. With a web application using BOSH to communicate to an XMPP server, we have 3 levels: the XMPP server itself, a BOSH connection manager, and the web application. Since HTTP is stateless, and XMPP is not (it's designed to maintain a persistent connection), we need to use a BOSH connection manager to maintain that persistent connection to the XMPP server. This connection manager is what's managing our session with the server and handling the intermittent requests from the web application, it's able to push messages to the client with Comet.
In order for the BOSH connection manager to validate the intermittent requests coming from the web application, we include a SID and a RID attribute with each stanza. The SID will remain the same during the lifetime of the session, and the RID will increment by 1 with each outgoing request. It is important that the RID is incremented properly, if a request with an unexpected RID is sent to the connection manager, the session is usually ended and the connection manager will return an error.
Hope that helps.
Alright, I have
Server 1 which browsers connect to, and where the HTTP session is handled automatically by Weblogic.
Server 2 which receives events from a third server
The user/browser is sitting idle, ie. not making any calls to Server 1 so the HTTP session times out after the specified timeout period
When server 2 receives certain events, I would need to refresh the HTTP session for a specific user at server 1.
The only way I have come up with is this:
In server 1, store the session id somewhere where it's accessible by server 2
When the event to refresh the session is received in server 2, make an HTTP call with the session cookie to server 1 (some dummy resource), simulating a call from the browser.
But I don't want do the HTTP call (and haven't actually tested it either) since it requires changes also in the firewall etc and in general feels kludgy. Instead I would like to send a message (using JMS for example) from server 2 to server 1, and then use some API to refresh the session. But I haven't found such API to exist.
So, do you know of a API that I can use for refreshing the session using the session id, or can you think of some other way to do this?
You can do it either by:
1. Using Server-Side push which will in turn invoke http to server 1 from 2. Atmosphere for example.
2. Have a scheduler in server 2 which will check for that event and send a request to server 1.
I am using SignalA android client library in my android application for getting real time data push from server.
i am able to establish the connection with server using HubConnection specified in SignalA framework. After some time(10 or 5 mins once), SignalA tries to reconnect the connection, that i could captured in the callback method(onStateChanged) of HubConnection. Once the connection state was reached 'Reconnecting' state, it is not connecting with the Server further. It always retains the same state as 'Reconnecting'. it is not establishing the connection again.
In this scenario, i am failing to get push from server.
Can anyone provide the solution on this like how can i establish the connection again?
Check out the new version of SignalA. This was a bug that is hopefully fixed in the new version.