Spring controller is getting called twice at test environment - javascript

I have been facing an issue with spring controller for a long time. Even after a lot of research over this spring controller redirection issues that didn't give any solution.
Issue: We are doing some payment integrations such as Sofort, AliPay and PayPal using Spring. Everything working fine in local machine(PC desktop) whereas it causes the issue with PayPal at test enviroments(Cloud deployment servers);however, remaining all other payment types are working fine.
There is the PayPal response handler url(Controller) at merchant server where it handles the paypal payment response, the handler url is getting called twice. Therefore, its not giving appriopriate results as it should get called only once.
PayPal Response Handler URL:
us/en-us/checkout/payment/paypal/handleResponse?token=EC-XXXXXXXXXXXX&PayerID=XXXXXX
Observations:
a) Whenever we have such kind of issues that is url getting called twice. At network tab of chrome, JS could be the issue. But, we haven't found such kind of history at there.
b) We use load balancer at our test environments. At sometimes, load balancer would make the url to get called twice. But, we didn't find a such kind of calls at loadbalancer.
c) Spring Handler method as below.
#RequestMapping(path = "/handleResponse", method = RequestMethod.GET)
public String handleResponse(#RequestParam(name = "token")
final String token, #RequestParam(name = "PayerID")
final String payerId)
d) There is no issue with PayPal configurations or PayPal servers. If I would hit the browser with the sample url below it is getting called twice, eventhough its not sending from PayPal. Hence, there is no issue with PayPal.
https://ABCDMERCHANT.com/us/en-us/checkout/payment/paypal/handleResponse?token=EC-XXXXXXXXXXX&PayerID=XXXXXXXXXXX
Guys, If could you give any suggestions to trace it down the root cause of it. that will be helpful for me.
Thanks InAdvance!!

We had given fixes to handle the second call however, during further tests even still it was failed and found the root cause and given the fix.
Root Cause: PayPal test environment, takes more than 45 seconds to complete set, get, authorize/capture and place order requests but the Application server time out is 10 seconds there its failed hence it makes second call.
Fix: we have increased the server time out to 50 seconds and its stopped making second request.

Related

Using #azure/event-hubs sending message always run into a timeout

I am trying to send a message to the configured eventhub for implicit grand flow.
I try to get the following example to run for sending to event hub. I get to the point when the user/client needs allow the azure application. But after then when I am using the created producer - I get a timeout after 2 minutes. (The request with message_id "xxx" to "$cbs" endpoint timed out. Please try again later.)
What can causes this type of error? When I am producing messages in .net everything is working fine. And if its because of auth issue (because of the complex configuration) I would get an other error (like I got before I set it up correctly)
Some other infos:
I gave the app registration only "Azure Event Hubs Data Send" role and I put the role to the app twice one time on the subscription level and one directly in the event hub (IAM). Can this double role cause an error - no or?

oidc-client CheckSessionIFrame fires properly one time, then fails ever interval thereafter

This may not actually be an issue with Identity Server or the oidc-client, but I am having trouble pinning down the problem. I am running this through System.js in an Aurelia application, so it's possible the issue originates from one of these external libraries.
In CheckSessionIFrame.start(session_state), we have the following code:
this._timer = window.setInterval(() => {
this._frame.contentWindow.postMessage(this._client_id + " " + this._session_state, this._frame_origin);
}, this._interval);
The first time the interval fires, there appear to be no problems. The iFrame's contentWindow exists (as expected) and the postMessage method is called without issue. Two seconds later, when the interval fires again, this._frame.contentWindow is undefined - so my best guess is the iFrame is dying somehow. Again, this may not be an issue with oidc-client, but I'm looking for any helpful guidance on what could cause this iFrame to die (perhaps internally it could be dying on a script?) such as a missing necessary config value for oidc-client.
For oidc-client to work with silent renew, you need to have your aurelia-app on an element that is not the body, so you can place elements within the body yet outside of your aurelia-app.
This allows you to put the IFrame outside of the aurelia-app, which prevents the Aurelia bootstrapper from eating it and lets oidc-client function independently of Aurelia.
EDIT
Based on your comment, and a little memory refreshing on my part, I rephrase/clarify:
The session checker and the silent renew functions work independently of each other. You can silent renew before the session checker has started with a manual call. You can also start the session checker without doing any silent renew. They are just convenient to use together, but that's their only relationship.
I'm assuming you use the hybrid flow and have the standard session checker implementation with an RP and OP iframe, where the OP iframe is in a check_session.html page and the RP iframe is somewhere in your aurelia app. In one of my projects I have the RP iframe in the index.html, outside of the aurelia-app element so it works independently of aurelia. But I guess it doesn't necessarily have to be there.
The session checker starts when you set the src property of the RP iframe to the location of your check_session.html with the session_state, check_session_iframe and client_id after the hash.
The check_session.html page will respond to that by starting the periodic polling and post a message back to the window of your aurelia app if the state has changed.
From your aurelia app, you listen to that message and do the signinSilent() call if it indicates a changed state. And from the silent_renew.html page, you respond to that with signinSilentCallback()
All that being in place, it really doesn't matter when you start the session checker. Tuck it away in a feature somewhere and load that feature last.
The only two things you need to worry about during the startup of your application is:
Check for window.hash starting with #code and call signinRedirectCallback(code) if it does
If it does not, just call signinSilent() right away (that leaves you with the least amount of things to check)
And then after either of those have been done, do getUser() and check if it's null or if the expired property === true. If either of those is the case, do the signinRedirect(). If not, your user is authenticated and you can let the aurelia app do it's thing and start the session checker etc.
I would definitely not put the initial authentication checks on your index.html within the aurelia-app. Because if aurelia happens to finish loading before the oidc checks are done, the process will fail. You also probably want to store the user object (and UserManager) in some cache/service/other type of singleton class so you can easily interact with oidc from your aurelia application.

BreezeJs: SaveChanges() server response getting dropped

I have breezeJs running in an angular app on mobile device (cordova), which talks to .Net WebApi.
Everything works great, except once in a while the device will get PrimaryKey violations (from my SQL Server).
I think I narrowed it down to only happening when data connection is shakey on the device.
The only way I can figure these primary key violations are happening is somehow the server is Saving Changes, but the mobile connection drops out before the response can come back from server that everything saved OK.
What is supposed to happen when BreezeJS doesn't hear back from server after calling SaveChanges?
Anyone familiar with BreezeJS know of a way to handle this scenario?
I've had to handle the same scenario in my project. The approach I took was two part:
Add automatic retries to failed ajax requests. I'm using breeze with jQuery, so I googled "jQuery retry ajax". There's many different implementations, mine is somewhat custom, all center around hijacking the onerror callback as well as the deferred's fail handler to inject retry logic. I'm sure Angular will have similar means of retrying dropped requests.
In the saveChanges fail handler, add logic like this:
...
function isConcurrencyException(reason: any) {
return reason && reason.message && /Store update, insert, or delete statement affected an unexpected number of rows/.test(reason.message);
}
function isConnectionFailure(reason: any): boolean {
return reason && reason.hasOwnProperty('status') && reason.status === 0
}
entityManager.saveChanges()
.then(... yay ...)
.fail(function(reason) {
if (isConnectionFailure(reason)) {
// retry attempts failed to reach server.
// notify user and save to local storage....
return;
}
if (isConcurrencyException(reason)) {
// EF is not letting me save the entities again because my previous save (or another user's save) moved the concurrency stamps on the record. There's also the possibility that a record I'm try to save was deleted by another user.
// recover... in my case I kept it simple and simply attempt to reload the entity. If nothing is returned I know the entity was deleted. Otherwise I now have the latest version. In either case a message is shown to the user.
return;
}
if (reason.entityErrors) {
// We have an "entityErrors" property... this means the saved failed due to server-side validation errors.
// do whatever you do to handle validation errors...
return;
}
// an unexpected exception. let it bubble up.
throw reason;
})
.done(); // terminate the promise chain (may not be an equivalent in Angular, not sure).
One of the ways you can test spotty connections is to use Fiddler's AutoResponder tab. Set up a *.drop rule with a regex that matches your breeze route and check the "Enable Automatic Responses" box when you want to simulate dropped requests.
This is a somewhat messy problem to solve- no one size fits all answer, hope this helps.
NOTE
Ward makes a good point in the comments below. This approach is not suitable in situations where the entity's primary key is generated on the server (which would be the case if your db uses identity columns for PKs) because the retry logic could cause duplicate inserts.

Unhandled Exception: System.TimeoutException: The request channel timed out while waiting for a reply after 00:01:59.4579323

i am new to crm2011
i tried creating a plugin and then registering it with the Plugin Registration tool
here is the code for Plugin.cs file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Microsoft.Xrm.Sdk;
using Xrm;
using System.Runtime.Serialization;
namespace NewPlugin
{
public class Plugin : IPlugin
{
/// <summary>
/// A plugin that creates a follow-up task activity when a new account is created.
/// </summary>
/// <remarks>Register this plug-in on the Create message, account entity,
/// and asynchronous mode.
/// </remarks>
public void Execute(IServiceProvider serviceProvider)
{
//Extract the tracing service for use in debugging sandboxed plug-ins.
ITracingService tracingService =
(ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];
throw new InvalidPluginExecutionException("Plugin could not be registered");
}
} }
}
}
but While i register this plugin i get the below error
Unhandled Exception: System.TimeoutException: The request channel timed out while waiting for a reply after 00:01:59.4579323. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
Server stack trace:
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Xrm.Sdk.IOrganizationService.Create(Entity entity)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.CreateCore(Entity entity)
at Microsoft.Crm.Tools.PluginRegistration.RegistrationHelper.RegisterAssembly(CrmOrganization org, String pathToAssembly, CrmPluginAssembly assembly)
at Microsoft.Crm.Tools.PluginRegistration.PluginRegistrationForm.btnRegister_Click(Object sender, EventArgs e)
Inner Exception: System.TimeoutException: The HTTP request to 'https://demoorg172.api.crm.dynamics.com/XRMServices/2011/Organization.svc' has exceeded the allotted timeout of 00:01:59.9970000. The time allotted to this operation may have been a portion of a longer timeout.
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
Inner Exception: System.Net.WebException: The operation has timed out
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Please help me if u can solve this.
Here this will help anyone struggling with this: Check this website out: azure preconfiguured it's ready to be compiled and has a one click method and is already on azure. My second guess was correct you didn't have all the appropriate ports and firewall off and buying a certificate and a domain...... So just check that out and compile it real simple. I don't like crm2011 but I know way more about it now than I did. I didn't know I could do ajax and javascript and pretty much anything thru iframe. Cheers hope this makes things easier.
Nice so you are fairly new to crm and cs scripts for Iplugins? The SDK is great, more than enough.
Your lines look fairly tight but I see a few lines that need a little scrubbing. I don't spend very much time with crm but I do have a little knowledge in it due to the fact that a plugin is just and executable script, so very similar to JavaScript, Ajax, python, html....
It look's like to me when you are using the argument // Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];
///Everything looks perfect up to that point but the service providers all have time
exceptions or if, they just don't like you pulling off of them if you don't have super
clean code. It will throw a fit and knock you off every time within probably a little over
a minute. When you are trying to pull the context params off you need to let it know what
you are doing with a so before this line of code you are going to need to put in a time
exception argument which allocates you time.
///I don't know what exactly your target is but it is a domain correct?
If so you just need to throw an exception at it that will allow you
to register and stay there all damn day if you please.
///when it throws this "System.TimeoutException" it then proceeds to give you a miniscule
amount of time to respond because it is a script so it can execute however fast the ping is.
Right before you request anything use this exception
//<serviceProvider.TimeoutException="Target"></client>
///if it wants to keep being stubborn than continue to clean up your lines and use the
/></system argument whenever it throws a fit about time. reminds me a lot of old
school html and python.
/// If you are actually going one on one with the server you can throw a
//<serviceProvider or
<domain.GetService.TimeoutException="reqast_info">*</client>
///That should allow it to continue without losing any packets or throwing
any "time" exception
///Ipv6 Protocols work really well. Also Open ports on the domain tcp and udp and sock 4
and 5 then the highest volume consumed ports the
port 80 and 25...... well Lets just say it is the most forgiving port and easiest going
there is.
///I hope I wasn't to late , but if I was than I am happy you got that "HelloWorld.cs"
Registered. Anyways man hope all is well. Sorry If I am not a huge help because I have,
probably sounds and looks just like JavaScript.
///When I was reading the handler exception, I noticed a portion that was talking about a "Boolean"
This can be significant because it can really throttle any incoming data down to a crippling demoralizing fail every time. Just like a full blown firewall except there are no exceptions.
"String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs"
The Boolean works as a packet filter. And it's not set for in and out traffic. So it can push a ton of packets but it just receives enough to be able to do it's job. I remember proxy servers... real proxy servers at school called mcproserver port 8080, tunneling and very aggressive." And proxy servers also slow way down the more traffic they are throwing around.
Do a little investigative work on that domain and get their ipv6 address and run some net challenges thru the terminal so you can find out exact what the limits are on the other-side, im going to say it clears logs and dynamically drops the proxy one of several hundred they rotate; every two hours, if you weren't tunneling thru to it via a client than it would kick you off in exactly 2 seconds. They server itself probably resets itself once ever 7 days. It's most likely an A+AAAA class and ridiculous. That Boolean also caps the bandwidth at which the proxy server can down-link complex packets.
First off you have to have a secure registered account or it will never go anywhere and second the domain:'https://demoorg172.api.crm.dynamics.com/XRMServices/2011/Organization.svc' doesn't even exist as a domain at all so that could be your whole issue because it is failing to establish a connection for two hours. There is no way. Your lines are great very simply. Shit better than me. and I can't get to any portion of that domain by either pinging it or nslookup
So It looks like to me you will have to first establish a secure connection via client I assume or if you know the port and you have authorization than you can run some tests on the server so you can not just continue to waste your time just to find out it cannot establish a http connection with it.
Your plugin has nothing to do with it. You aren't establishing a proper connection with the domain therefore probably losing 90 percent of packets or just shuts you down from the get go but will wait two hours if you are using terminal start the net share or send and tunnel in with elevated privileges then login instead of using a webrowser or client. Then once if you can establish a conection with the domain and it's not dropping packets and if it exists than you are golden.
But either you need to open a few ports on your end and open your nat and make a firewall exception or it is on there end. Most likely the former. You can still try adding the lines I slopped up for you which do allocate more time. But now that I got farther into it. It took your plugin fine cooked it and then synched up and then down towards the very bottom after it's done doing everything it throws a 0 and shuts you down. I am sure I just wasted my time typing this because I just realized it was asked 3 months ago. Hope you are excelling in your abilities by this time.
P.s. before I forget, the Timeout could be a Buffer Overflow a very small one that kicks you off while you are trying to register. But I guarantee that there is only an astronomical chance that it would execute and trip whatever you are pulling the target off. If it is anything like python then you can slightly alter the lines I typed with to make them "div" extension and just an easier way to go in my personal experience:
<div class="row-fluid">
</div>
<div class="row-fluid">
<div class="span6">
<label>
<input type="text" name=name of the domain that you are using."
<span class="inline_error_message error_"></span>
</div>
<div class="span6">
<input type="text" name="" value= />
<span class="inline_error_message error_">_</span>
</div>
<div class="row-fluid">
///These are java script row-fluid
///I doubt those will help
Does this fix it? I'm about to try it...
http://social.microsoft.com/Forums/en-US/8b408943-45cc-4104-b3f8-5f926312c7bc/crm-2011-plugin-registration-tool-timeout-error?forum=crmdevelopment

IE hang for 5 minutes when calling synchronous xmlhttprequest

I have a web application and use ajax to call back to my webserver to fetch data.
Sometimes(at rather unpredictable moments, but it can be reproduced) IE hangs completely for 5 minutes(the window says Not Responding) and then comes back and the xmlhttprequest object responds with error 12002.
The way I can reproduce it is as follows.
Open window(B) from main window(A) using button
Window A calls synchronous ajax(PROC1) when button is clicked to open window B. PROC1 Runs file.
New window(B) has ajax code(PROC2) and calls server asynchronous. Runs fine
User closes Window B after PROC2 completed but before data is returned.
In Main Window(a) user clicks button again. PROC1 runs again but now the send() call blocks for 5 minutes.
Please help. I've been looking for 3 days.
Please note:
* I can't test it in firefox (the app is not firefox compatible)
* I have to use synchronous calls (that's the way the app is constructed and it would take too much developer effort to rewrite it)
Why does this happen and how to I fix this?
You're right Jaap, this is related to Internet Explorer's connection limit of 2. For some reason, IE doesn't release connections to AJAX requests performed in closed windows.
I have a very similar situation, only slightly simpler:
User clicks in Window A to open Window B
Window B performs an Ajax call that takes awhile
Before the Ajax call returns, user closes Window B. The connection to this call "leaks".
Repeat 1 more time until both available connections are "leaked"
Browser becomes unresponsive
One technique you can try (mentioned in the article you found) that does seem to work is to abort the XmlHttp request in the unload event of the page.
So something like:
var xhr = null;
function unloadPage() {
if( xhr !== null ) {
xhr.abort();
}
}
Another option is to use synchronous AJAX calls, which will block until the call returns, essentially locking the browser. This may or may not be acceptable given your particular situation.
// the 3rd param is whether the call is asynchronous
xhr.open( 'get', 'url', false );
Finally, as mentioned elsewhere, you can adjust the maximum number of connections IE uses in the registry. Expecting visitors to your site to do this however isn't realistic, and it won't actually solve the problem -- just delay it from happening. As a side-note, IE8 is going to allow 6 concurrent connections.
Thanks for answering Martijn.
It didn't solve my issues. I think what I'm seeing is best described on this website:
http://bytes.com/groups/javascript/643080-ajax-crashes-ie-close-window
In my situation I have an unstable connection or a slow webserver and when the connection is too slow and the browser and the webserver still have a connection then freezes.
By default Internet Explorer only allows two concurrent connections to the same website for download purposes. If you try and fire up more than this, I.E. stalls until one of the previous requests finishes at which point the next request will complete. I believe (although I could be wrong) this was put in place to prevent overloading websites with many concurrent downloads at a time. There is a registry hack to circumvent this lock.
I found these instructions kicking around the internet which alleviated my problems - I can't promise it will work for your situation, but the multi-connection limit you're facing appears related:
Click on the Start button and select Run.
On the Run line type Regedt32.exe and hit Enter. This will launch the Registry Editor
Locate the following key in the registry:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
Click on the Internet Settings Key.
Now go to the Edit menu, point to NEW
click DWORD Value
Type MaxConnectionsPer1_0Server for the name of this DWORD Value.
Double-click on the MaxConnectionsPer1_0Server key you just created and enter the following information: Value data: 10. Base: Decimal.
When finished press OK.
Repeat steps 4 through 9. This time naming the key MaxConnectionsPerServer and assigning it the same values as indicated in Steps 8.
When finished press OK
Close the Registry Editor.
Of course, I would use these in conjunction with the abort() call previously mentioned. In tandem, they should fix the issue.
IE5 and IE6, indeed, do hang when attempting to receive data from a PHP script. The reason is that these browsers can not decide when has all of the data been received and the connection can be closed. So they wait until connection expires (thus the 5 or 10 minute hang). A way to solve this is to tell to the browser how much data it will receive. In PHP you can do that using output buffering, for example as follows:
ob_start();
echo $html_content;
header( 'Connection: close' );
header( 'Content-Length: '.ob_get_length() );
flush();
ob_end_flush();
This is a solution when one is just loading a normal web page. When one is using
AJAX GET via Microsoft.XMLHTTP object it is enough to
send the "Connection: close" header with the GET request, like
r.request.open( "GET", url, true );
r.request.setRequestHeader( "Connection", "close" );
r.request.send();
Winsock Error 12002 means the following according to msdn
ERROR_INTERNET_TIMEOUT
12002
The request has timed out.
Winsock is the underlying socket transfer object for XMLHTTP in IE so any error thats not in the HTTP error range (300,400,500 etc) is almost always a winsock error.
What wasnt clear from your question is wheter the same resource is being queried the 2nd time round. You could force a new uncached resource by appending:
'?uid=+'Math.random()
To the URL which might solve the issue.
another solution might be to attach a function to the "onbeforeunload" event on the window object to call abort() an any active XMLHTTP request just before the window B is closed.
Hope these 2 pointers solve your bug.
All these posts - Disable PDF reader.. and that stuff... will not resolve your problem...
But sure shot is - RUN WINDOWS UPDATE .. keep uptodate.. This issue gets resolved by itself..
Experience speaks ;)
HydTechie

Categories

Resources