Debugging - API call failure in server environment - debugging

I have an API that works perfectly locally.
The API is published to the server using a standard pipeline in Devops in combination with Octopus and has worked this way for years without the issue that I am facing.
I recently published a change and now find that certain calls to the API fail.
Bizarrely when publishing the same code to my local filesystem and manually copying to the server the API again works as expected!
The response to the call is incredibly unhelpful:-
date: Fri,21 Oct 2022 11:09:12 GMT
server: Microsoft-IIS/10.0
strict-transport-security: max-age=2592000
x-powered-by: ASP.NET
I have attempted to wrap the contents of the controller method in a try catch block and have any exceptions get returned, but this does not work.
I've also tried to use EventLog, but it's not creating any logs at all on this server. EventLog works fine on the live server so that's another issue!
I feel like the code being published is different to that I checked in but I'm unsure how to rectify this.
I would mostly like to know what it is that's causing the failure, and how I could possibly debug the thing! Which is the advice I'm looking for here.
Update: I have found my issue, it was an appsetting pointing to an out-of-date location.
It doesn't explain why copying and pasting previously fixed the issue as the setting was present in that version as well.
I would very much like to know if there any guides or advice on how to approach debugging this situation for future reference.

Related

Proxy / cache server for development purposes

I'm working on a mobile client. Dev backend server, I'm working with, isn't stable at all. It may be unusable for a full working day. Prod server is a bit better but still sometimes it doesn't work either. The other problem is it's much more difficult to use it in development. Besides that it's completely wrong to work like that. Basically these servers have been made for web, not for mobile. And it has other strange and annoying thing that destructs me from my primary work - token life time is only 60 seconds. That means if the app didn't refresh the token in that period the token dies. And next time you run the app you need to authorize from scratch. And that process takes centuries(((. May be I just don't understand how it works or something, but as I see web site just spams the sever every minute.
I was thinking how to fix this problem and started using mocking manually. But it's very annoying and time consuming either. The other idea is to use some kind of proxy / cache server that will send request to original server and if it fails return cached data. It seems that it may help in my situation. I'm not sure would such proxy / cache server be able to eliminate token problem. Basically I need to refresh it as soon as first token has been received. But who knows? May be I'm lucky enough?)
So the question: is there some simple to use proxy cache server that I will be able to run locally to achieve what I want?
The other opportunity is to write such proxy server myself. I have no experience in writing servers at all. But as a last chance I could try. The benefit of writing proxy server myself is that I should be able to "fix" token problem for sure. But I don't want to reinvent the wheel.
So any help and thoughts are appreciated.
Not entirely sure if this will solve your problem but let's give it a shot.
I myself have been programming against a rate-limited API. During development I often max out the allowed requests and have to wait before I could continue. I have developed a small caching proxy server that sits between your client and the server. It intercepts the requests and puts both the request and response in it's cache. Whenever it intercepts a request that it's already seen it will respond from cache without forwarding the request to the target server.
I'm not sure what your requests look like. The proxy that I build currently retrieves cache based on URL and HTTP Method, so that may or may not be what you need.
Here's the link to the GitHub repository: https://github.com/RobinvandenHurk/cache-proxy
Disclaimer: For if it wasn't clear, I am the author of this proxy

PHP7 IIS10 Windows Authentication returning various different AD-Users in AUTH_USER and REMOTE_USER

I have a very annoying problem as shortly described in the title. As I don't know which settings would make sense to post here and due to the fact, that exactely the same web application was running before on a Server 2008 with IIS 7 seamlessly, I try to explain the occuring misbehaviour as good as possible. I'd appriciate your ideas or hints very much.
Our web application was running for years now on the 2008 server with IIS7, PHP5.6 in FastCGI Mode. We authenticate our users by "Windows Authentication" (NTLM/Negotiate) against Active Directory and therefor just letting the users enter their domain users credentials at start of the session. Actually we allways used named sessions like this: SESS_[TIMESTAMP] and looped the timestamp through the whole applications session untill it was destroyd by whatever - closing, leaving, etc.
Now we migrated the web application to a new Server 2019 with IIS10 and PHP7.4. The application it self works as expected and absolutely with no problems at all. The only thing causing a critical situation is as follows:
I enter the web application on my machine, enter the credentials and - as expectet - am in. I see my Username at the top, everything is ok. As I go through workflows and data manipulations it's also working correctly. BUT: If my colleague in his homeoffice now enters the web application and starts working at the same time as I do, very often I see his username at the top of my browser window and he is me... (???) As we both then press F5 sometimes, the session changes back and forth. As our users (inside company) work with security sensitive data, this is indeed a showstopper.
As far as I can say, I really checked all settings in IIS and php.ini against the settings on the old server and also searched the web for days now. With absolutely no success.
I even commented out the section at my sessions initiation that sets a custom session_name. And indeed I'm not using a custom folder for session files.
The only thing I'm quite sure is that the misbehaviour results out of a misconfiguration in IIS: If I only open a test-file with phpinfo(), I can reproduce the same behaviour. The AUTH_USER, REMOTE_USER and LOGON_USER are changing back and forth between another users DOMAIN\username and mine.
Does anybody have had this interesting but annoying behaviour also? Any ideas or hints where to apply the lever?
Thank you so much for your input.
New information to my question:
I found out that the most significant difference to the old server is a load balancer! It seams that the load balancing causes this problem as the old server was not balanced.
Any suggestions or ideas how to deal with this?

How to trouble shoot and resolve XrmToolBox Plugin Registration tool not connecting?

Seems like every other day XrmToolBox's Plugin Registration tool fails to connect. It's probably the most fickle tool I've ever used professionally (is this really the best tool for the job? yikes)
In years of working with it, I've not yet found a reliable way to get the tool to connect. Everything connects fine in the browser. But XrmToolBox randomly fails.
And I've never found or read online a reliable way to figure it out except restart your computer, throw salt over your shoulder, spin counter-clockwise once in your chair, try again later.
Anyone have a better way?
The server was unable to process the request due to an internal error.
For more information about the error, either turn on
IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute
or from the configuration behavior) on the server in
order to send the exception information back to the client, or turn on
tracing as per the Microsoft .NET Framework SDK documentation and
inspect the server trace logs.
That was the only error I got from XrmToolBox. But it led me to solving the problem. Followed this article to enable more detailed error log:
https://community.adxstudio.com/products/adxstudio-portals/documentation/developers-guide/knowledge-base/enable-detailed-errors-on-the-organization-service/
Tried again, and saw that indeed there was a meaningful error in the XrmToolBox logs.
TL;DR: Turn on better error logging in the on-premise CRM web.config! Then try again to get a more helpful error.

How to log Dynamics CRM standard SOAP API calls?

Context
We have an on-premise CRM (8.0) application, which is integrated with different legacy systems. There are approx 20 entities which are created/updated/upserted via the standard SOAP API by the legacy systems.
Question
I would like to log all the incoming requests and responses as SOAP/XML for diagnostics reasons. How can I accomplish this task?
(Note: I know the trivial, but not exactly fit solution to have workflows for create/update on all affected entities. This seems to be not universal enough + we ultimately must log the request text and response text itself)
I haven't tried it yet, but I think it should be possible to configure the native WCF tracing for the Organization Service. This is something really easy to do (it requires to add some configuration to the web.config file) and you will be able to log any request and response. You can take a look about how to configure it here.
EDIT:
In this link you will be able to see what I've just told you working (it was done for CRM2011 but it should works in newer versions): link

Disable SOAP Schema Validation, JAX-WS and JAXB, How?

Out of the blue several previously working SOAP calls I do from Java code give "DefaultValidationEventHandler: [ERROR]: unexpected element...".
It is complaining about about the response object. A few things though; it had been working fine, I did not change the schema or the EJB, or the caller code, I do no have a scheme validation feature on the port, and the response looks just fine to me. It is the client side that is complaining. The server successfully executes the request without comment.
I think my Eclipse environment may be malfunction.
Is there a way to disable client side schema validation of the response from the service or port object?
I figured this out and it was Eclipse (Helios) as I suspected. It turns out that if anything is incorrect with the Java EE perspective and/or any enterprise projects, Eclipse will quietly stop rebuilding things.
I found this out when I deleted everything under build/classes, and then nothing would run. An unrelated project was pointed at a no longer valid server profile.
How this resulted in the behavior I saw is unknown. And it would still be nice to know how to disable validation. It is supposed to off by default, but that but is not.

Resources