Azure Service Bus - MessageLockLostException when app is in Docker container, works fine otherwiseHow to list containers in DockerHow to remove old Docker containersCopying files from Docker container to hostCopying files from host to Docker containerWhat is the difference between a Docker image and a container?From inside of a Docker container, how do I connect to the localhost of the machine?Azure App hosted docker port 25MassTransit stop consuming messages from queue after reach MaxConcurrentCalls on Azure Service BusOpen ports on Azure Service BusDocker Container fails to start in an Azure App Service

Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?

How does Loki do this?

Customer Requests (Sometimes) Drive Me Bonkers!

You cannot touch me, but I can touch you, who am I?

Anatomically Correct Strange Women In Ponds Distributing Swords

Where does the Z80 processor start executing from?

Is oxalic acid dihydrate considered a primary acid standard in analytical chemistry?

What can we do to stop prior company from asking us questions?

Integer addition + constant, is it a group?

Would this custom Sorcerer variant that can only learn any verbal-component-only spell be unbalanced?

Is there a korbon needed for conversion?

Proof of work - lottery approach

Tiptoe or tiphoof? Adjusting words to better fit fantasy races

Purchasing a ticket for someone else in another country?

Short story about space worker geeks who zone out by 'listening' to radiation from stars

Is this apparent Class Action settlement a spam message?

Is `x >> pure y` equivalent to `liftM (const y) x`

Is expanding the research of a group into machine learning as a PhD student risky?

Escape a backup date in a file name

Crossing the line between justified force and brutality

How to pronounce the slash sign

Go Pregnant or Go Home

How do I go from 300 unfinished/half written blog posts, to published posts?

What is the intuitive meaning of having a linear relationship between the logs of two variables?



Azure Service Bus - MessageLockLostException when app is in Docker container, works fine otherwise


How to list containers in DockerHow to remove old Docker containersCopying files from Docker container to hostCopying files from host to Docker containerWhat is the difference between a Docker image and a container?From inside of a Docker container, how do I connect to the localhost of the machine?Azure App hosted docker port 25MassTransit stop consuming messages from queue after reach MaxConcurrentCalls on Azure Service BusOpen ports on Azure Service BusDocker Container fails to start in an Azure App Service













2















We have a .NET Core console app that serves the role of a Saga/Process manager.



This Saga app communicates with other microservices via Azure Service Bus (with the use of MassTransit for messaging abstraction - MassTransit.Azure.ServiceBus)



The app contains a state machine (MassTransit/Automatonymous) that handles events - triggered by Service Bus messages.



In the current scenario the initial Saga event is triggered from an Azure Function App by publishing a message via MassTransit:



busControl.Publish(createSearchPageLinkEvent);


NOW, when:



a) the Saga app is ran as-is, (no containerization) - everything works fine, the event is handled correctly.



b) the Saga app is put into a Docker container, locally (using docker-compose in VS2017) - an Exception occurs. In essence - it seems that upon Publishing the message indeed reaches the Saga app, however the following Exception occurs instantly (excerpt):




Exception received on receiver:
sb://***.servicebus.windows.net/link_provider_saga during RenewLock,
Microsoft.Azure.ServiceBus.MessageLockLostException: The lock supplied
is invalid. Either the lock expired, or the message has already been
removed from the queue




Here is the message handling code in the state machine (Automatonymous) that never gets reached when dockerized:



 Initially(
When(CreateSearchPageLinkEvent)
.Then(context =>

//Exception occurs before we get here
_log.Information($"context.Instance.CorrelationId CreateSearchPageLinkEvent for ");
context.Instance.PropertyType = context.Data.PropertyType;
context.Instance.SideName = context.Data.SideName;
context.Instance.TransactionType = context.Data.TransactionType;
context.Instance.Url = context.Data.Url;
)


Here is the docker-compose config:



 version: '3.4'

services:
saga.azure:
image: $DOCKER_REGISTRY-sagaazure
build:
context: .
dockerfile: AcquireLinkTaskTracking.AzureDockerfile
ports:
- "443:443"
- "5671:5671"
- "5672:5672"
- "9350-9354:9350-9354"


Here is the app's DockerFile:



FROM microsoft/dotnet:2.1-runtime-nanoserver-1803 AS base
WORKDIR /app

FROM microsoft/dotnet:2.1-sdk-nanoserver-1803 AS build
WORKDIR /src

RUN dotnet restore AcquireLinkTaskTracking.Azure/Saga.Azure.csproj
//(...) Lots of dependendcy copying here
COPY . .
WORKDIR /src/AcquireLinkTaskTracking.Azure
RUN dotnet build Saga.Azure.csproj -c Debug -o /app

FROM build AS publish
RUN dotnet publish Saga.Azure.csproj -c Debug -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Saga.Azure.dll"]


Why would Docker cause communication issue?
My hunches are:



a) incorrect port mapping/publishing - however the triggering microservice obviously reaches the container somehow



b) The TLS protocol/certificate (used by Azure Service Bus) are not set up correctly (not a trivial thing to do)



PS the dockerized Saga app is launched from VS2017 locally by "Start Debugging" wth docker-compose



PS2 using EXPOSE for port 80 in the Dockerfile did not solve the issue










share|improve this question




























    2















    We have a .NET Core console app that serves the role of a Saga/Process manager.



    This Saga app communicates with other microservices via Azure Service Bus (with the use of MassTransit for messaging abstraction - MassTransit.Azure.ServiceBus)



    The app contains a state machine (MassTransit/Automatonymous) that handles events - triggered by Service Bus messages.



    In the current scenario the initial Saga event is triggered from an Azure Function App by publishing a message via MassTransit:



    busControl.Publish(createSearchPageLinkEvent);


    NOW, when:



    a) the Saga app is ran as-is, (no containerization) - everything works fine, the event is handled correctly.



    b) the Saga app is put into a Docker container, locally (using docker-compose in VS2017) - an Exception occurs. In essence - it seems that upon Publishing the message indeed reaches the Saga app, however the following Exception occurs instantly (excerpt):




    Exception received on receiver:
    sb://***.servicebus.windows.net/link_provider_saga during RenewLock,
    Microsoft.Azure.ServiceBus.MessageLockLostException: The lock supplied
    is invalid. Either the lock expired, or the message has already been
    removed from the queue




    Here is the message handling code in the state machine (Automatonymous) that never gets reached when dockerized:



     Initially(
    When(CreateSearchPageLinkEvent)
    .Then(context =>

    //Exception occurs before we get here
    _log.Information($"context.Instance.CorrelationId CreateSearchPageLinkEvent for ");
    context.Instance.PropertyType = context.Data.PropertyType;
    context.Instance.SideName = context.Data.SideName;
    context.Instance.TransactionType = context.Data.TransactionType;
    context.Instance.Url = context.Data.Url;
    )


    Here is the docker-compose config:



     version: '3.4'

    services:
    saga.azure:
    image: $DOCKER_REGISTRY-sagaazure
    build:
    context: .
    dockerfile: AcquireLinkTaskTracking.AzureDockerfile
    ports:
    - "443:443"
    - "5671:5671"
    - "5672:5672"
    - "9350-9354:9350-9354"


    Here is the app's DockerFile:



    FROM microsoft/dotnet:2.1-runtime-nanoserver-1803 AS base
    WORKDIR /app

    FROM microsoft/dotnet:2.1-sdk-nanoserver-1803 AS build
    WORKDIR /src

    RUN dotnet restore AcquireLinkTaskTracking.Azure/Saga.Azure.csproj
    //(...) Lots of dependendcy copying here
    COPY . .
    WORKDIR /src/AcquireLinkTaskTracking.Azure
    RUN dotnet build Saga.Azure.csproj -c Debug -o /app

    FROM build AS publish
    RUN dotnet publish Saga.Azure.csproj -c Debug -o /app

    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app .
    ENTRYPOINT ["dotnet", "Saga.Azure.dll"]


    Why would Docker cause communication issue?
    My hunches are:



    a) incorrect port mapping/publishing - however the triggering microservice obviously reaches the container somehow



    b) The TLS protocol/certificate (used by Azure Service Bus) are not set up correctly (not a trivial thing to do)



    PS the dockerized Saga app is launched from VS2017 locally by "Start Debugging" wth docker-compose



    PS2 using EXPOSE for port 80 in the Dockerfile did not solve the issue










    share|improve this question


























      2












      2








      2








      We have a .NET Core console app that serves the role of a Saga/Process manager.



      This Saga app communicates with other microservices via Azure Service Bus (with the use of MassTransit for messaging abstraction - MassTransit.Azure.ServiceBus)



      The app contains a state machine (MassTransit/Automatonymous) that handles events - triggered by Service Bus messages.



      In the current scenario the initial Saga event is triggered from an Azure Function App by publishing a message via MassTransit:



      busControl.Publish(createSearchPageLinkEvent);


      NOW, when:



      a) the Saga app is ran as-is, (no containerization) - everything works fine, the event is handled correctly.



      b) the Saga app is put into a Docker container, locally (using docker-compose in VS2017) - an Exception occurs. In essence - it seems that upon Publishing the message indeed reaches the Saga app, however the following Exception occurs instantly (excerpt):




      Exception received on receiver:
      sb://***.servicebus.windows.net/link_provider_saga during RenewLock,
      Microsoft.Azure.ServiceBus.MessageLockLostException: The lock supplied
      is invalid. Either the lock expired, or the message has already been
      removed from the queue




      Here is the message handling code in the state machine (Automatonymous) that never gets reached when dockerized:



       Initially(
      When(CreateSearchPageLinkEvent)
      .Then(context =>

      //Exception occurs before we get here
      _log.Information($"context.Instance.CorrelationId CreateSearchPageLinkEvent for ");
      context.Instance.PropertyType = context.Data.PropertyType;
      context.Instance.SideName = context.Data.SideName;
      context.Instance.TransactionType = context.Data.TransactionType;
      context.Instance.Url = context.Data.Url;
      )


      Here is the docker-compose config:



       version: '3.4'

      services:
      saga.azure:
      image: $DOCKER_REGISTRY-sagaazure
      build:
      context: .
      dockerfile: AcquireLinkTaskTracking.AzureDockerfile
      ports:
      - "443:443"
      - "5671:5671"
      - "5672:5672"
      - "9350-9354:9350-9354"


      Here is the app's DockerFile:



      FROM microsoft/dotnet:2.1-runtime-nanoserver-1803 AS base
      WORKDIR /app

      FROM microsoft/dotnet:2.1-sdk-nanoserver-1803 AS build
      WORKDIR /src

      RUN dotnet restore AcquireLinkTaskTracking.Azure/Saga.Azure.csproj
      //(...) Lots of dependendcy copying here
      COPY . .
      WORKDIR /src/AcquireLinkTaskTracking.Azure
      RUN dotnet build Saga.Azure.csproj -c Debug -o /app

      FROM build AS publish
      RUN dotnet publish Saga.Azure.csproj -c Debug -o /app

      FROM base AS final
      WORKDIR /app
      COPY --from=publish /app .
      ENTRYPOINT ["dotnet", "Saga.Azure.dll"]


      Why would Docker cause communication issue?
      My hunches are:



      a) incorrect port mapping/publishing - however the triggering microservice obviously reaches the container somehow



      b) The TLS protocol/certificate (used by Azure Service Bus) are not set up correctly (not a trivial thing to do)



      PS the dockerized Saga app is launched from VS2017 locally by "Start Debugging" wth docker-compose



      PS2 using EXPOSE for port 80 in the Dockerfile did not solve the issue










      share|improve this question
















      We have a .NET Core console app that serves the role of a Saga/Process manager.



      This Saga app communicates with other microservices via Azure Service Bus (with the use of MassTransit for messaging abstraction - MassTransit.Azure.ServiceBus)



      The app contains a state machine (MassTransit/Automatonymous) that handles events - triggered by Service Bus messages.



      In the current scenario the initial Saga event is triggered from an Azure Function App by publishing a message via MassTransit:



      busControl.Publish(createSearchPageLinkEvent);


      NOW, when:



      a) the Saga app is ran as-is, (no containerization) - everything works fine, the event is handled correctly.



      b) the Saga app is put into a Docker container, locally (using docker-compose in VS2017) - an Exception occurs. In essence - it seems that upon Publishing the message indeed reaches the Saga app, however the following Exception occurs instantly (excerpt):




      Exception received on receiver:
      sb://***.servicebus.windows.net/link_provider_saga during RenewLock,
      Microsoft.Azure.ServiceBus.MessageLockLostException: The lock supplied
      is invalid. Either the lock expired, or the message has already been
      removed from the queue




      Here is the message handling code in the state machine (Automatonymous) that never gets reached when dockerized:



       Initially(
      When(CreateSearchPageLinkEvent)
      .Then(context =>

      //Exception occurs before we get here
      _log.Information($"context.Instance.CorrelationId CreateSearchPageLinkEvent for ");
      context.Instance.PropertyType = context.Data.PropertyType;
      context.Instance.SideName = context.Data.SideName;
      context.Instance.TransactionType = context.Data.TransactionType;
      context.Instance.Url = context.Data.Url;
      )


      Here is the docker-compose config:



       version: '3.4'

      services:
      saga.azure:
      image: $DOCKER_REGISTRY-sagaazure
      build:
      context: .
      dockerfile: AcquireLinkTaskTracking.AzureDockerfile
      ports:
      - "443:443"
      - "5671:5671"
      - "5672:5672"
      - "9350-9354:9350-9354"


      Here is the app's DockerFile:



      FROM microsoft/dotnet:2.1-runtime-nanoserver-1803 AS base
      WORKDIR /app

      FROM microsoft/dotnet:2.1-sdk-nanoserver-1803 AS build
      WORKDIR /src

      RUN dotnet restore AcquireLinkTaskTracking.Azure/Saga.Azure.csproj
      //(...) Lots of dependendcy copying here
      COPY . .
      WORKDIR /src/AcquireLinkTaskTracking.Azure
      RUN dotnet build Saga.Azure.csproj -c Debug -o /app

      FROM build AS publish
      RUN dotnet publish Saga.Azure.csproj -c Debug -o /app

      FROM base AS final
      WORKDIR /app
      COPY --from=publish /app .
      ENTRYPOINT ["dotnet", "Saga.Azure.dll"]


      Why would Docker cause communication issue?
      My hunches are:



      a) incorrect port mapping/publishing - however the triggering microservice obviously reaches the container somehow



      b) The TLS protocol/certificate (used by Azure Service Bus) are not set up correctly (not a trivial thing to do)



      PS the dockerized Saga app is launched from VS2017 locally by "Start Debugging" wth docker-compose



      PS2 using EXPOSE for port 80 in the Dockerfile did not solve the issue







      docker azureservicebus servicebus masstransit automatonymous






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 13:18







      sztepen

















      asked Mar 7 at 12:55









      sztepensztepen

      6817




      6817






















          2 Answers
          2






          active

          oldest

          votes


















          0















          Why would Docker cause communication issue?




          Networking issue I suspect. Intermittent errors will take place and as a user you have to retry. And it's not just Docker where you could run into this problem.



          RenewLock is a client-side initiated operation and is not guaranteed to be successful. As such, failure to renew the message lock should be handled by a retry mechanism. You'd need to confirm with MassTransit if that's implemented or not. If not, your code will continue processing message assuming lock was extended when it wasn't. And when completion of an incoming message will be attempted, you'll get the MessageLockLostException exception.






          share|improve this answer






























            0














            Ok, so this was a simple issue:



            We simply used the wrong base image. The asp net core runtime image was needed. The diff to our dockerfile goes like this:



            -FROM microsoft/dotnet:2.1-runtime-nanoserver-1803 AS base
            +FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016 AS base

            -FROM microsoft/dotnet:2.1-sdk-nanoserver-1803 AS build
            +FROM microsoft/dotnet:2.1-sdk-nanoserver-sac2016 AS build


            you live, you learn.






            share|improve this answer






















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55044327%2fazure-service-bus-messagelocklostexception-when-app-is-in-docker-container-wo%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0















              Why would Docker cause communication issue?




              Networking issue I suspect. Intermittent errors will take place and as a user you have to retry. And it's not just Docker where you could run into this problem.



              RenewLock is a client-side initiated operation and is not guaranteed to be successful. As such, failure to renew the message lock should be handled by a retry mechanism. You'd need to confirm with MassTransit if that's implemented or not. If not, your code will continue processing message assuming lock was extended when it wasn't. And when completion of an incoming message will be attempted, you'll get the MessageLockLostException exception.






              share|improve this answer



























                0















                Why would Docker cause communication issue?




                Networking issue I suspect. Intermittent errors will take place and as a user you have to retry. And it's not just Docker where you could run into this problem.



                RenewLock is a client-side initiated operation and is not guaranteed to be successful. As such, failure to renew the message lock should be handled by a retry mechanism. You'd need to confirm with MassTransit if that's implemented or not. If not, your code will continue processing message assuming lock was extended when it wasn't. And when completion of an incoming message will be attempted, you'll get the MessageLockLostException exception.






                share|improve this answer

























                  0












                  0








                  0








                  Why would Docker cause communication issue?




                  Networking issue I suspect. Intermittent errors will take place and as a user you have to retry. And it's not just Docker where you could run into this problem.



                  RenewLock is a client-side initiated operation and is not guaranteed to be successful. As such, failure to renew the message lock should be handled by a retry mechanism. You'd need to confirm with MassTransit if that's implemented or not. If not, your code will continue processing message assuming lock was extended when it wasn't. And when completion of an incoming message will be attempted, you'll get the MessageLockLostException exception.






                  share|improve this answer














                  Why would Docker cause communication issue?




                  Networking issue I suspect. Intermittent errors will take place and as a user you have to retry. And it's not just Docker where you could run into this problem.



                  RenewLock is a client-side initiated operation and is not guaranteed to be successful. As such, failure to renew the message lock should be handled by a retry mechanism. You'd need to confirm with MassTransit if that's implemented or not. If not, your code will continue processing message assuming lock was extended when it wasn't. And when completion of an incoming message will be attempted, you'll get the MessageLockLostException exception.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 7 at 18:09









                  Sean FeldmanSean Feldman

                  9,61323051




                  9,61323051























                      0














                      Ok, so this was a simple issue:



                      We simply used the wrong base image. The asp net core runtime image was needed. The diff to our dockerfile goes like this:



                      -FROM microsoft/dotnet:2.1-runtime-nanoserver-1803 AS base
                      +FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016 AS base

                      -FROM microsoft/dotnet:2.1-sdk-nanoserver-1803 AS build
                      +FROM microsoft/dotnet:2.1-sdk-nanoserver-sac2016 AS build


                      you live, you learn.






                      share|improve this answer



























                        0














                        Ok, so this was a simple issue:



                        We simply used the wrong base image. The asp net core runtime image was needed. The diff to our dockerfile goes like this:



                        -FROM microsoft/dotnet:2.1-runtime-nanoserver-1803 AS base
                        +FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016 AS base

                        -FROM microsoft/dotnet:2.1-sdk-nanoserver-1803 AS build
                        +FROM microsoft/dotnet:2.1-sdk-nanoserver-sac2016 AS build


                        you live, you learn.






                        share|improve this answer

























                          0












                          0








                          0







                          Ok, so this was a simple issue:



                          We simply used the wrong base image. The asp net core runtime image was needed. The diff to our dockerfile goes like this:



                          -FROM microsoft/dotnet:2.1-runtime-nanoserver-1803 AS base
                          +FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016 AS base

                          -FROM microsoft/dotnet:2.1-sdk-nanoserver-1803 AS build
                          +FROM microsoft/dotnet:2.1-sdk-nanoserver-sac2016 AS build


                          you live, you learn.






                          share|improve this answer













                          Ok, so this was a simple issue:



                          We simply used the wrong base image. The asp net core runtime image was needed. The diff to our dockerfile goes like this:



                          -FROM microsoft/dotnet:2.1-runtime-nanoserver-1803 AS base
                          +FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016 AS base

                          -FROM microsoft/dotnet:2.1-sdk-nanoserver-1803 AS build
                          +FROM microsoft/dotnet:2.1-sdk-nanoserver-sac2016 AS build


                          you live, you learn.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 10 at 21:36









                          sztepensztepen

                          6817




                          6817



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55044327%2fazure-service-bus-messagelocklostexception-when-app-is-in-docker-container-wo%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              1928 у кіно

                              Захаров Федір Захарович

                              Ель Греко