question

MikeEangelo-6600 avatar image
0 Votes"
MikeEangelo-6600 asked MikeEangelo-6600 answered

Weird Exception in App Service

Hi All,

I am seeing a weird intermittent exception in my logs:

Microsoft.JSInterop.JSException: jQuery is not a function
TypeError: jQuery is not a function
    at Module.NewDocumentElement (https://<id>.azurewebsites.net/_content/DragonSpark.Presentation//Environment/Browser/Document/DocumentElement.js:12:32)
    at https://<id>.azurewebsites.net/_framework/blazor.server.js:1:3501
    at new Promise (<anonymous>)
    at kt.beginInvokeJSFromDotNet (https://<id>.azurewebsites.net/_framework/blazor.server.js:1:3475)
    at https://<id>.azurewebsites.net/_framework/blazor.server.js:1:72001
    at Array.forEach (<anonymous>)
    at kt._invokeClientMethod (https://<id>.azurewebsites.net/_framework/blazor.server.js:1:71987)
    at kt._processIncomingData (https://<id>.azurewebsites.net/_framework/blazor.server.js:1:70029)
    at vt.connection.onreceive (https://<id>.azurewebsites.net/_framework/blazor.server.js:1:64432)


What's weird about this is the root URI where this exception is occurring, and I want to verify this. I have my .azurewebsites.net seen above, but it also is forwarded to a custom domain. According to the exception message, it appears this is occurring in the azurewebsites.net location, but I cannot verify this. I am looking in the event log and it does not say which URL this occurs in.

When an exception occurs, is there some way of seeing what the requested URI/host was when this occurred?

To further round this out, what's weird about this is that if this indeed occurring in my .azurewebsites.net address, that is entirely unexpected and a little worrisome, as I have never broadcasted this URI and I am wondering how someone might find this. The only address I have advertised is the custom domain, and I am worried if my .azurewebsites.net address is somehow being leaked somewhere with my configuration.

Thank you for any assistance you can provide,
Michael

azure-webappswindows-server-iisdotnet-aspnet-core-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OK I was able to look in my HTTP logs and I do a bunch of traffic to the .azurewebsites.net address. To further add to the mystery, I did get the IP address when the exception occurred, but it does not show up in the HTTP logs. It's very weird and concerning to me to get traffic to the .azurewebsites.net address as I have not promoted that at all and am wondering how this is being acquired.

0 Votes 0 ·
Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered MikeEangelo-6600 commented

Your blazor server code is doing a JavaScript interop to call jQuery, but the jQuery library is not loaded. Check your use of jQuery.



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for the reply/suggestion @Bruce-SqlWork. Note that jQuery is present and the first thing loaded. The exception occurred on an iPhone which I cannot readily test, unfortunately.

In any case, I am more concerned about where the error is occurring, i.e. .azurewebsites.net vs custom domain. The stacktrace above states .azurewebsites.net and I am wanting to verify that this is indeed the location this exception occurred and not the custom domain.

Further, I am also concerned that my .azurewebsites.net address is somehow being leaked, as I have not broadcasted/promoted/linked this location and it is somehow already receiving traffic, despite only having created it a few days ago.

0 Votes 0 ·
Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered MikeEangelo-6600 commented

Error indicates jQuery was not loaded. Maybe the hosting site not a available or blocked. or a scripting error is produced. Are you using an async load?

The reported url is the url of the blazor.server.js file you are hosting.

· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Correct @Bruce-SqlWork it is reporting https://<id>.azurewebsites.net/_framework/blazor.server.js so that means the request is being made from https://<id>.azurewebsites.net and not the custom domain, correct?

0 Votes 0 ·

No. That is the domain name of the .site hosting the .js file throwing the error. If just view source on the page, you will see the <script> tag with that domain as the source.

While the request may be the same domain, it doesn’t need to be. Also you are using server blazor, so the “requests” are over the signal/r websocket. And the error was generated by the server calling the client over signal/r. There was no request.

0 Votes 0 ·

Right, so how do I find the host/request URL of where this error occurred? FWIW this is the script tag:

<script src="/_framework/blazor.server.js"></script>
0 Votes 0 ·
Show more comments
JasonPan-MSFT avatar image
0 Votes"
JasonPan-MSFT answered MikeEangelo-6600 commented

Hi @MikeEangelo-6600

Bruce's analysis is correct, the fundamental reason is that jquery is not loaded. I read your original post and I can assume that your webapp is working fine on pc's browser. It just doesn't load properly in the iPhone's safari browser.

Please let me know if my understanding is wrong. My suggestion is as follows:

  1. First make sure that we can access the webapp normally using the PC without encountering this error.

  2. Download the Chrome or Edge app on your iPhone, then go ahead and try accessing the webapp

If you follow the above steps and find that everything is normal, then you can conclude that the safari browser in the iOS system intercepts the jquery file under the https://<id>.azurewebsites.net site. Regarding the safari browser in iOS, we normally encounter the phenomenon that the video cannot be opened, so we have reason to doubt whether our site is not trusted, which causes the file to fail to be loaded.

We can try to replace the jquery file in the project with the code below.

 <script src="https://code.jquery.com/jquery-1.12.4.js"></script>


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Best Regards,
Jason

· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for your reply @JasonPan-MSFT. I do understand the error, but what is weird is where it is occurring, as I cannot verify/validate the exact location of the request. As I mentioned to Bruce in the comments, I do not have an iPhone so I cannot readily test this again at will ATM. Please note that my jQuery include is the first script include tag in my document and looks like this:

<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>


However, to reiterate, the issue is not exactly that jQuery does not load, but where this exception is occurring. If I am getting traffic to https://<id>.azurewebsites.net this is concerning to me as I have not promoted/advertised this URL and it's already getting traffic after only a few days of creating its related AppService instance. If errors are occurring here because they are using https://<id>.azurewebsites.net instead of my intended custom domain, then I am not so worried this is occurring. However, I am worried that my https://<id>.azurewebsites.net address is being leaked somewhere/somehow and would like to mitigate this if so and possible.

Thank you for any continued assistance you can provide.

0 Votes 0 ·

FYI/FWIW I received this exception again but this time on a Windows 10/Chrome machine. This is my configuration and I have never seen this error despite clearing cache and trying incognito.

That stated, I have been testing on my custom domain and not my https://<id>.azurewebsites.net address. However, even trying this there I do not see this exception caused. Very confused on how this is happening especially when jquery is the first listed <script></script> tag in my application.

0 Votes 0 ·

Hello @MikeEangelo-6600

Please search globally in your project to see if https://<id>.azurewebsites.net is hardcoded in the code.

Best regards,
Jason

0 Votes 0 ·

Of course, @JasonPan-MSFT. :) This is not there in any part of my solution which is why I am concerned here. The only URLs/locations I have in my solution are my custom domains. Again this is especially perplexing/concerning as I stood up completely new App Service instances with new names last week, so I would definitely have to change them in my SLN if they were there or else obvious breakage would occur. Furthermore, they are already being queried without me promoting/advertising them. So, to me, that seems to imply the URL is being leaked somewhere.

0 Votes 0 ·

To 100% verify @JasonPan-MSFT I did a solution-wide search and the only places azurewebsites.net occur in my SLN are in older pubxml files made in January with the old App Service names. They are not the new names that I created last week and are somehow already being actively queried (and subsequently crashing) in the wild.

0 Votes 0 ·

Hi @JasonPan-MSFT I can confirm that with the extra logging errors continue to be thrown on https://<id>.azurewebsites.net but not on my custom domain. It would be nice to know how people were able to access this address as I did not promote it at all. Thank you for any continued assistance you can provide.

0 Votes 0 ·
MikeEangelo-6600 avatar image
1 Vote"
MikeEangelo-6600 answered MikeEangelo-6600 commented

I've updated my logging to include the root URI of the calling request, so that will solve some problems in the interim. However:

  1. It really feels the request URI should already be available somewhere, so I am duplicating existing functionality which hinders performance

  2. It is still unclear how requests are being made to my https://<id>.azurewebsites.net address rather than my configured custom domain

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Confirming that these errors are only occurring on https://<id>.azurewebsites.net. Sort of baffling on how this is happening.

0 Votes 0 ·
MikeEangelo-6600 avatar image
0 Votes"
MikeEangelo-6600 answered

This still occurs. Another error:

Microsoft.JSInterop.JSException: bootstrap is not defined
ReferenceError: bootstrap is not defined
    at eval (eval at <anonymous> (https://<id>.azurewebsites.net/_framework/blazor.server.js:1:3501), <anonymous>:1:1)
    at eval (<anonymous>)
    at https://<id>.azurewebsites.net/_framework/blazor.server.js:1:3501
    at new Promise (<anonymous>)

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MikeEangelo-6600 avatar image
0 Votes"
MikeEangelo-6600 answered

Got another request to my azurewebsites.net address, this time with a bitdiscovery UserAgent

https://bitdiscovery.com/

Is this a known partnership with Azure or something, perhaps?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.