getsentry / raven-csharp

Superseded by: https://github.com/getsentry/sentry-dotnet
BSD 3-Clause "New" or "Revised" License
231 stars 121 forks source link

Client Returns 403 (Forbidden) when capturing using Microsoft Azure #254

Closed jamesmundy closed 6 years ago

jamesmundy commented 6 years ago

I've been struggling with a strange issue. The client works locally on my PC in debug and release modes and logs exceptions but when I deploy to Azure the client is unable to log any exceptions. I have attached a debugger and discovered every call to Sentry is returning 403: Forbidden and causing an exception.

Are Azure servers somehow blacklisted from using Sentry? My code is pretty simple:

public class SentryBugTrackingService : IBugTrackingService
    {
        private readonly RavenClient _client;

        public SentryBugTrackingService(IAppSettingsService appSettingsService)
        {
            _client = new RavenClient(appSettingsService.SentryKey);
            _client.ErrorOnCapture += ErrorOnCapture;
        }

        public async Task LogBugAsync(Exception e)
        {
            var sentryEvent = new SentryEvent(e);
            var response = await _client.CaptureAsync(sentryEvent);
        }

        private void ErrorOnCapture(Exception exception)
        {
        }

        public void LogBug(Exception e)
        {
            var sentryEvent = new SentryEvent(e);
            _client.Capture(sentryEvent);
        }
    }

I'm using exactly the same DSN locally as when deployed to Azure.

jamesmundy commented 6 years ago

Ok, this isn't related to this library but to some internal filters at Sentry. The Azure Data Centre I am using has been blocked:

{Connection: keep-alive
X-Content-Type-Options: nosniff
Content-Language: en
X-Sentry-Error: Event dropped due to filter: web-crawlers
Vary: Accept-Language, Cookie
X-XSS-Protection: 1; mode=block
X-Frame-Options: deny
X-Served-By: web-ee8f0660
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Content-Length: 53
Cache-Control: max-age=0
Content-Type: application/json
Date: Fri, 25 May 2018 09:42:41 GMT
Expires: Fri, 25 May 2018 09:42:41 GMT
Last-Modified: Fri, 25 May 2018 09:42:41 GMT
Server: nginx
} 
jamesmundy commented 6 years ago

Resolved with the help of this article: https://gitlab.com/gitlab-com/infrastructure/issues/2060 There are filters you can adjust in settings which I wasn't aware of. Turning the web-crawler option off worked and I am not receiving events.