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.
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
I have a java client app and a java server app.
My client can have network slowdown.
My client performs SOAP webservices to my server app. The problem is that sometimes the client reach its timeout (40sec) because the network is really, really bad.
For the client app this request is a fail, and it retry the same call a bit later. But the server had already integrated the data from client, and I get violated keys error from my ORM.
I do not want to prolong the timeout on the client side.
My question is: when the client timeout, is there a way to rollback everything on the server side ?
Thanks
One of the options to solve it is to set some flag/status in the database when request is accepted by server. Something like inProcessing. And change this flag to Complete after successful data processing.
When client will retry the same call later you can check this flag and if flag=inProcessing or Complete don't do any date processing.
I am running a test script on jmeter. The design of the system I'm testing is multi-profile. Meaning, as I login using an HTTP server, I am redirected to either Server1 or Server2 (randomly). On the test script I recorded, I was redirected to Server2. So whenever I run this pre-recorded test script again (with 100 users/threads), only those requests redirected to Server2 are processed successfully and those requests redirected to Server1 are returning a 'User session Not Found' error. How do I fix this?
I have an HTTP Cache and HTTP Cookie Manager in my test plan before the HTTP samplers.
It seems like a bad configuration of two servers as they are not sharing the session data. normally, the servers share the session related information such as cookies so that client can get the response from either of the servers.
I am not sure whether you can really control which server to hit (though it hit the second server during recording, because load balancer has chosen that server for you at that point in time), it is completely Load balancer decision (based on the algorithms used, like least response times, client IP-based etc)
I suggest to check the server configurations whether they are sharing cookie level data or not. Also, suggest check which algorithm is being used by the load balancer to distribute the load across two servers.
If they are not causing the issues, then look at how the cookies are sent by the server and how the(JMeter) client is resending them (by HTTP Cookie Manager) i.e., check whether Cookies are sent by the JMeter as expected by the server(s). sometimes it is possible that partial cookies are being sent.
Please answer the following questions:
Is the request always sent to Server2 when one thread is used?
Whether the request is getting succeeded when the requests hit the server1 for single thread?
Are you hitting the load balancer URL (which inturn decides the server to hit)? Or hardcoded one of the server address?
I'm developing a Java API for an Adndroid app in Spring. Right now my API is 100% REST and stateless. For the client to receive data, it must send a request first.
However, what I need is the server to send data to the to the client /not the client to the server fisrt/ whenever it is ready with it's task.
I think that some kind of session must be created between the two parties.
My question is: How can I achieve this functionality of the SERVER sending data to the CLIENT when it's ready with it's task? /It is unknown how long the task will take./
What kind of API should I develop for this purpose?
One idiotic workaround is sending a request to the server every n seconds but I'm seeking for a more intelligent approach.
There are multiple options available. You can choose what suits best for you.
Http Long Polling - In this, server holds the request until it's ready with its task (in your case). Here, you don't have to make multiple requests every few seconds (Which is Http Polling).
Server Sent Events - In this, server sends update to the client without long-polling. It is a standardized part of HTML 5 - https://www.w3.org/TR/eventsource/
Websockets - Well, websockets work in duplex mode and in this a persistent TCP connection is established. Once TCP connection is established, both server and client sends data to and fro. Supported by most modern browsers. You can check for Android Websocket Library like autobahn and Java websocket.
SockJs - I would recommend to go with this option instead of plain WebSocket. http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#websocket-fallback-sockjs-enable
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.