Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "cangunaydin"

Answer

Hello @ismcagdas it is difficult to say but we didn't get any exception until now. i will close the issue for now. if sth happens i can open a new thread thank you for your help.

Answer

i will try it @ismcagdas, i am not using it.

Answer

Also i need to say before this exception, i am getting out of memory exception. But i don't see any memory issue on the metrics not in backend or redis cache. Maybe after this exception signalr also goes down since it uses redis?

ERROR 2022-12-15 16:06:08,713 [129 ] Abp.Runtime.Caching.Redis.AbpRedisCache - StackExchange.Redis.RedisConnectionException: Failed to write ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.Threading.Thread.StartInternal(ThreadHandle t, Int32 stackSize, Int32 priority, Char* pThreadName) at System.Threading.Thread.StartCore() at System.Threading.Thread.Start(Object parameter, Boolean captureContext) at StackExchange.Redis.PhysicalBridge.WriteMessageTakingWriteLockAsync(PhysicalConnection physical, Message message) in //src/StackExchange.Redis/PhysicalBridge.cs:line 1012 --- End of inner exception stack trace --- at Abp.Runtime.Caching.Redis.AbpRedisCache.TryGetValueAsync(String key) at Abp.Runtime.Caching.AbpCacheBase2.GetAsync(TKey key, Func2 factory) StackExchange.Redis.RedisConnectionException: Failed to write ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.Threading.Thread.StartInternal(ThreadHandle t, Int32 stackSize, Int32 priority, Char* pThreadName) at System.Threading.Thread.StartCore() at System.Threading.Thread.Start(Object parameter, Boolean captureContext) at StackExchange.Redis.PhysicalBridge.WriteMessageTakingWriteLockAsync(PhysicalConnection physical, Message message) in //src/StackExchange.Redis/PhysicalBridge.cs:line 1012 --- End of inner exception stack trace --- at Abp.Runtime.Caching.Redis.AbpRedisCache.TryGetValueAsync(String key) at Abp.Runtime.Caching.AbpCacheBase2.GetAsync(TKey key, Func2 factory)

Hello again, I was trying couple of things to be sure about the problem. I make it work by doing couple of things. First of all i need to state that i am using hangfire on my app. Since hangfire is polling the database i see lots of dependency logs, so to fix that issue i have implemented custom telemetry processor. This stackoverflow link was helpful for that https://stackoverflow.com/questions/38320886/app-insights-disable-sql-dependency-telemetry

using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.DataContracts;

public class NoSQLDependencies : ITelemetryProcessor
{
    private ITelemetryProcessor Next { get; set; }

    // Link processors to each other in a chain.
    public NoSQLDependencies(ITelemetryProcessor next)
    {
        this.Next = next;
    }
    public void Process(ITelemetry item)
    {
        if (IsSQLDependency(item)) { return; }
        this.Next.Process(item);
    }

    private bool IsSQLDependency(ITelemetry item)
    {
        var dependency = item as DependencyTelemetry;
        if (dependency?.DependencyTypeName == "SQL")
        {
            return true;
        }
        return false;
    }
}

Afterwards I explicitly configured Hangfire to use Log4net by this code inside WebHostModule PreInitialize()

GlobalConfiguration.Configuration.UseLog4NetLogProvider();

now everythings work fine on my local machine. There is only one thing left i couldn't understand. if you look at the code below.

    public class TestAppService : BookAndAdAppServiceBase
    {
        private readonly IBackgroundJobManager _backgroundJobManager;

        private readonly ILogger _logger;
        public TestAppService(IBackgroundJobManager backgroundJobManager, ILogger logger)
        {
            _backgroundJobManager = backgroundJobManager;
            _logger = logger;
        }

        public async Task TestLogger()
        {
            Logger.Error($"Application Insights test from {nameof(TestAppService)}....", new Exception("this is custom exception"));
            _logger.Error($"Application Insights test with reference (can2) {nameof(TestAppService)}");
            await _backgroundJobManager.EnqueueAsync<TestJob, TestJobArgs>(new TestJobArgs() { TenantId = AbpSession.TenantId,UserId=AbpSession.UserId },delay:TimeSpan.FromSeconds(10));
        }
    }

as you can see first logger is logging with exception, and this is coming to application insights as exception which is expected. On the other hand second logger since it doesn't pass any exception it is logged as Trace. Which at first sight seems weird since i call Error() method. But anyway it works fine, i think we can close this.

Hello @ismcagdas Not really helped. Actually i realize that if i log it by using ilogger in application layer or in controller, i can see it in application insights, but background job and background worker errors are not logged at all (I am using Hangfire for it.) What i couldn't understand is, i can see the hangfire errors on text file that i append to azure appservice root folder. They both use log4net, why fileappender can do it but not application insights appender? I really couldn't grasp it. Do you have any idea?

Hello @ismcagdas, thanks for the reply, How can i create the background job from an entity? shouldn't I need to inject IBackgroundJobManager? Can you give me a code example if there is a way to do it inside the entity?

I am closing this then. thank you for the time.

Hello @ismcagdas thank you for the answer. Over here I try to simplify the things, but sometimes deleting operations in our project can have some business rules. For ex deleting an order can only be done in some kind of state. I understand it can't be done for now, but what I would like to ask is

can I mark some entities with an interface. So instead of using IRepository interface use another repository interface and restrict users to use IRepository on the application layer somehow with those entities?

Thank you @ismcagdas, i am closing this issue.

Hello @ismcagdas

Thank you for the reply. I was wondering, if this behavior is new? antiforgery token is not used on anz version 8 or 9? Was it like this from the start of anz or if sth has changed on the latest version? Cause normally I am working on google chrome to test the things that i developed and when i try to get the antiforgery token in chrome browser, it gives me a valid value and it is not null.

Probably on my chrome browser, cookie with antiforgery token has been set long time ago. When i try to open the application on incognito mode then cookie value is null. so i can not upload file in incognito mode but i can upload the file when i open the app with my normal chrome browser.

Normally we used the devex file uploader to make chunk uploads on the app so for every chunk that is gonna be sent to the server side, we decided to add authentication token value first without antiforgery. Then one of our developers try to upload a file and he got an error on the server side.

ERROR 2022-05-14 18:19:42,118 [orker] idateAntiforgeryTokenAuthorizationFilter - The required antiforgery request token was not provided in either form field "__RequestVerificationToken" or header value "X-XSRF-TOKEN". Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The required antiforgery request token was not provided in either form field "__RequestVerificationToken" or header value "X-XSRF-TOKEN". at Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery.ValidateRequestAsync(HttpContext httpContext) at Abp.AspNetCore.Mvc.Antiforgery.AbpValidateAntiforgeryTokenAuthorizationFilter.OnAuthorizationAsync(AuthorizationFilterContext context) INFO 2022-05-14 18:19:42,126 [orker] c.Infrastructure.ControllerActionInvoker - Authorization failed for the request at filter 'Abp.AspNetCore.Mvc.Antiforgery.AbpAutoValidateAntiforgeryTokenAuthorizationFilter'.

then we decided also to add an antiforgery token with the request. as i mentioned in my first post. Then as you can expect it didn't work if you do not have an old cookie value that has been set for the site. Right now we have removed all the cookies and remove the antiforgery token code that we are sending with the request.Now everything is working fine. But it is still a mystery how that cookie value is written if anz didn't use antiforgery token at all in all versions?

Showing 1 to 10 of 133 entries