Possible causes of duplicate requests to Signal-R hub (different ConnnectionIDs) - iframe

Our web-application is exhibiting an issue whereby we're seeing duplicate requests from a single user action (all details except ConnectionId are the same) in our Signal-R hub.
Assuming the first request was received at T0 then we saw duplicate requests at (approximately)
T0 + 2:00
T0 + 2:30
T0 + 3:30
T0 + 8:00
Effectively, the client-side JavaScript code sets up a connection to a Signal-R hub, when the user clicks the submit button it invokes a method on the hub (kicks off procesing in the back-end).
The problem has only started recently in production - we haven't changed any relevant code (client-side nor SignalR hub). The web-app is deployed in a corporate environment (users use IE11 via Citrix). I note that (presumably due to firewalls) SignalR is using forever-frames (rather than web-sockets etc).
In our logs (from the Signnal-R hub) the user-agent appears as Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.3)
The client code looks along the lines of
// Setup
self.myHub = $.connection.myHub;
$.connection.hub.start().done(function () {
console.debug("SignalR Hub Connected");
});
...
// When handling user action
self.myHub.server.someHubMethod(param1, param2);
Basically, I'm stumped as to what is going on / where I should be looking. My thoughts are that there is some caching proxy/web accelerator/spider or similar which is somehow replaying the requests.

Related

How to Act as Internet Explorer

I am using cefsharp in windows forms application. Somehow some sites need to run on internet explorer only. How can we set cefsharp (chromium) act like internet explorer?
I changed request headers to set user-agent like "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)" bu it did not solve my problem. The site still gets that the browser is not IE.
Could you please provide a solution?
Thanks for further help
I found the solution as faking the site like adding missing property/funcs to document object in frameloadstart event like this.
private void Browser_FrameLoadStart(object sender, FrameLoadStartEventArgs e)
{
browser.EvaluateScriptAsync(#"if(!document.all) { document.all = {};} if(!document.compatMode) { document.compatMode = 'BackCompat'} if(!document.getElementsByTagName){ document.getElementsByTagName = function(){}; } ");
}

Is Google Tag Manager sending extra events to Mixpanel through a proxy?

I configured GTM to load Mixpanel on every page on my domain and added click tracking on buttons like described on this blog: https://mixpanel.com/blog/2015/03/27/community-tip-implementing-mixpanel-via-google-tag-manager
This is not deployed to any server yet, just localhost, but it seems whenever clicks are being tracked, I get bogus events in mixpanel coming from the US on this url: https://gtm-msr.appspot.com/render2?id=GTM-XXXXX
with this user agent: Mozilla/5.0 (Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; EIE10;ENUSWOL; rv:11.0) like Gecko
Anyone encountered this before? Any idea's what is happening here?
This seems to happen whenever Google Tag Manager configurations are changed, possibly somewhere in the build process it's tested on an environment from the .appspot domain.
This can be rectified by only initializing mixpanel on non-offending domains:
if (document.location.href.search('.appspot.') == -1)
mixpanel.init(YOUR_TOKEN);
As a workaround I added a check in the mixpanel tracking code in GTM to filter out the bogus user agent. Of course, this works for now, until they change the user agent.
<script type="text/javascript">
if (navigator.userAgent != 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; EIE10;ENUSWOL; rv:11.0) like Gecko') {
var pagePath = {{Page Path}};
mixpanel.track("Page Loaded", {"Page Path": pagePath, "User Agent": navigator.userAgent});
}
</script>
Adding a filter in GTM itself doesn't work either, GTM ignores it.
I'm having the same issue and was thinking of checking where the page load was coming from before executing the code. This may be more convenient (doesn't depend on the user agent):
<script type="text/javascript">
if (document.location.href.search('.appspot.') == -1) {
/* run your code */
}
</script>
What you search for could be tweaked, but the odds this part of the URL will change is much less likely than the user agent.

Sending Requests To Mobile Sites Using HttpClient

I am new to Task-based programming and this new HttpClient class, but I read the examples and documentation on the MSDN and have a basic understanding of both. I tried to create a basic application that sends an async request, but it has already failed. It seems to be a problem with the URL, but have a look at the code first:
public static async void ScrapeDailyRaces()
{
HttpClient httpClient = new HttpClient();
Stream myStream = await httpClient.GetStreamAsync("https://mobile.bet365.com/");
}
When I tried to replace the URL with http://www.google.com, and also https://www.google.com, but they both worked so it isn't a problem with https. I also tried adding www to the faulty URL, resulting in https://www.mobile.bet365.com/, but it still doesn't work. Any ideas?
Exception details: "The underlying connection was closed: An unexpected error occurred on a receive." and "An error occurred while sending the request."
Just in case someone ran into the same problem, I fixed it by adding a user agent to the request using the following:
httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
Hope this helps.

Status of Internal websites by using PING

Afternoon All,
Just after a bit of advice on the best method to use for the following.
I am new ish to .net and have an Asp.net web page in development that i simply lists some internal web sites by a ping command and outlines their status (on-line / offline). This is current;y activated by the click of a button.
I need to set up this developemt web page so that it automatically runs at a specific time on a morning say 7am for arguments sake and to then notify a user group by email the status of these items.
I have used Microsoft Visual studio (VB) 2010 before and can create simple web works that connect/ extract/ update data to and from SQL 2008. I have also had some experience in creating scheduled jobs in SQL but not much.
I thought i could maybe create a scheduled job in SQL 2008, find a way to populate the data into the database, use this data in my website and display it a gridview or something. And either have the SQL job or the website email a group of users the status of these internal web sites.
Does anyone know if i would beable to complete the above just in .net? Am i able to write a script of some sort or schedule the web page to run at a specified time?
Im not 100% sure on the best method to tackle this job and i have limited experience. Can anyone suggest any best method ideas on how to complete the above.
Regards
Bet.
Although fairly trivial to implement, I don't believe a ping command is useful in the context of what you are trying to achieve.
As Fredrik pointed out, a ping only says that the server is available. It makes no statement as to whether an individual website is functional on that server.
If I was doing this I would create a service that runs every so often. The service would issue a get request to the web sites, do a little bit of parsing on the content to make sure what was returned was expected, and update a record in a database stating the time of the connection and the status (up/down).
For example:
public String CheckSite(String postLocation) {
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(postLocation);
// Setting the useragent seems resolves certain issues that *may* crop up depending on the server
httpRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
httpRequest.KeepAlive = false;
httpRequest.Method = "GET";
using ( HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse() ) {
using ( StreamReader reader = new StreamReader(httpResponse.GetResponseStream()) ) {
result = reader.ReadToEnd();
} // using reader
} // using httpResponse
return result;
}
This simple call will load a page from a server. From there you can parse to see if you have words like "error" or what have you. Provided it looks good then you report back that the site is up.
I know the above is C#, but you should be able to easily convert that to VB if necessary. You should also place a try .. catch around the call. If it errors out then you know the server is completely offline. If the page returns, but contains "error" or something then you know the server is up but the app is down.
pesronally . . . I think the most elegant solution would be: (untested)
public String CheckSite(String postLocation) {
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(postLocation);
// Setting the useragent seems resolves certain issues that *may* crop up depending on the server
httpRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
httpRequest.KeepAlive = false;
httpRequest.Method = "GET";
using ( HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse() ) {
if(httpResponse.StatusCode != {check for valid status codes here})
{
//Do something based upon an invalid response.
}
} // using httpResponse
return result;
}

Url fragment is empty

Using ASP.NET MVC3, the url http://localhost:22713/tests#123456 with the following code:
Your user agent: #Request.UserAgent<br />
Url: #Request.Url.AbsoluteUri<br />
Url fragment: #Request.Url.Fragment<br />
returns:
Your user agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16
Url: http://localhost:22713/tests
Url fragment:
Why is fragment always empty? I need to be able to parse this info on the server side.
The fragment (everything after the # in a url) doesn't get passed to the server. So the Fragment property will always be empty when you attempt to get it from a request.
The Fragment property is typically only used when constructing URLs.
There's no easy way to get the fragment on the server. Typically you would have to use javascript to retrieve the fragment.

Resources