Skip to content

[JENKINS-69955] WebSocketTimeoutException: Connection Idle Timeout #18351

Closed

Description

@jenkins-infra-bot

We first experienced the problem that websocket connections were closed down unexpectedly in Jenkins  2.361.1 LTS. The problem was reported in JENKINS-69509, and Jenkins 2.375 was released subsequently to address the issue. We tried Jenkins 2.375 and found the websocket problem still there. The websocket was closed down in less than 2 hours after the build started.  Attached all the necessary logs

Reverted back to  Jenkins 2.346.3 LTS is a workaround that works for us.

How to Reproduce

  • Start Jenkins 2.361.x or later with -Djenkins.websocket.pingInterval=120
  • Connect a Websocket agent
    --> Notice that the websocket agent disconnect/reconnect at every ping

An interval of 120 is a way to consistently see the error. Though it should happen with any value > 30. It may happen with the default 30 but with a lower likelihood.


Originally reported by gyu, imported from: WebSocketTimeoutException: Connection Idle Timeout
  • assignee: allan_burdajewicz
  • status: Closed
  • priority: Blocker
  • component(s): core
  • label(s): 2.387.2-fixed, remoting, websocket
  • resolution: Fixed
  • resolved: 2023-03-12T09:59:15+00:00
  • votes: 13
  • watchers: 25
  • imported: 2025-11-24
Raw content of original issue

We first experienced the problem that websocket connections were closed down unexpectedly in Jenkins  2.361.1 LTS. The problem was reported in JENKINS-69509, and Jenkins 2.375 was released subsequently to address the issue. We tried Jenkins 2.375 and found the websocket problem still there. The websocket was closed down in less than 2 hours after the build started.  Attached all the necessary logs

Reverted back to  Jenkins 2.346.3 LTS is a workaround that works for us.

How to Reproduce

  • Start Jenkins 2.361.x or later with -Djenkins.websocket.pingInterval=120
  • Connect a Websocket agent --> Notice that the websocket agent disconnect/reconnect at every ping

An interval of 120 is a way to consistently see the error. Though it should happen with any value > 30. It may happen with the default 30 but with a lower likelihood.

  • environment: Jenkins:2.361.1
15 attachments

Activity

  1. jenkins-infra-bot commented on Oct 26, 2022

    @jenkins-infra-bot
    Author
  2. jenkins-infra-bot commented on Oct 26, 2022

    @jenkins-infra-bot
    Author
    basil:
    • Original comment link
    • Raw content of original comment:

      Could you try running with the controller with --httpKeepAliveTimeout=120000 (or --httpsKeepAliveTimeout=120000)? I also notice your agents are running with an old version of Remoting (4.13.2); not likely to be related to this problem, but still worth upgrading to a more recent version.

    Could you try running with the controller with --httpKeepAliveTimeout=120000 (or --httpsKeepAliveTimeout=120000)? I also notice your agents are running with an old version of Remoting (4.13.2); not likely to be related to this problem, but still worth upgrading to a more recent version.

  3. jenkins-infra-bot commented on Oct 26, 2022

    @jenkins-infra-bot
    Author
    gyu:
    • Original comment link
    • Raw content of original comment:

      Can not experiment it now as our jenkins server is in production mode. However, before I reverted our jenkins version, I did try "--httpKeepAliveTimeout=3600000 --sessionEviction=-1 --sessionTimeout=90000". Strangely, the disconnect happened in a few minutes instead of less than 2 hours.  So with those settings the disconnect happened in minutes. Without those setting the disconnect happened in hours

    Can not experiment it now as our jenkins server is in production mode. However, before I reverted our jenkins version, I did try "--httpKeepAliveTimeout=3600000 --sessionEviction=-1 --sessionTimeout=90000". Strangely, the disconnect happened in a few minutes instead of less than 2 hours.  So with those settings the disconnect happened in minutes. Without those setting the disconnect happened in hours

  4. jenkins-infra-bot commented on Oct 26, 2022

    @jenkins-infra-bot
    Author
    basil:
    • Original comment link
    • Raw content of original comment:

      Without logs from when you were running with those settings I cannot be of much help I am afraid.

    Without logs from when you were running with those settings I cannot be of much help I am afraid.

  5. jenkins-infra-bot commented on Nov 2, 2022

    @jenkins-infra-bot
    Author
    gyu:
    • Original comment link
    • Raw content of original comment:

      Borrowed a new jenkins server and an agent, with Jenkins 2.375 installed, ran the job  with the controller with --httpKeepAliveTimeout=120000 and the build terminated after 12min. Collected all logs, attached. The names of the five logs/system info all contain "httpKeepAliveTimeout=120000"

    Borrowed a new jenkins server and an agent, with Jenkins 2.375 installed, ran the job  with the controller with --httpKeepAliveTimeout=120000 and the build terminated after 12min. Collected all logs, attached. The names of the five logs/system info all contain "httpKeepAliveTimeout=120000"

  6. jenkins-infra-bot commented on Nov 9, 2022

    @jenkins-infra-bot
    Author
    sbc8112:
    • Original comment link
    • Raw content of original comment:

      Face same issue, hope this can be fixed.

    Face same issue, hope this can be fixed.

  7. jenkins-infra-bot commented on Nov 9, 2022

    @jenkins-infra-bot
    Author
    basil:
    • Original comment link
    • Raw content of original comment:

      sbc8112 Have you tried increasing the timeout to two (2) minutes?

    sbc8112 Have you tried increasing the timeout to two (2) minutes?

  8. jenkins-infra-bot commented on Nov 10, 2022

    @jenkins-infra-bot
    Author
    sbc8112:
    • Original comment link
    • Raw content of original comment:

      Hi basil ,

       

      I have tried to update to v2.377 and add the --httpKeepAliveTimeout=120000 but the abnormal disconnect happened in hours. I will try to downgrade to v2.346 and check if this can help.

    Hi basil ,

     

    I have tried to update to v2.377 and add the --httpKeepAliveTimeout=120000 but the abnormal disconnect happened in hours. I will try to downgrade to v2.346 and check if this can help.

  9. jenkins-infra-bot commented on Nov 10, 2022

    @jenkins-infra-bot
    Author
    basil:
    • Original comment link
    • Raw content of original comment:

      Downgrading to 2.346 is a dead end, as there is very little chance we would revert back to Jetty 9 at this point. The question is how can we get users onto a stable deployment pattern on Jetty 10. A very small number of users are affected by this problem, and I suspect if pings aren't making it through within 2 minutes that those users have other problems with networking and/or CPU saturation impacting networking. But ultimately this timeout is configurable, so there should be a guaranteed workaround for anyone affected: just set the timeout to an extremely high value (e.g. 86,400,000 milliseconds which is 24 hours).

    Downgrading to 2.346 is a dead end, as there is very little chance we would revert back to Jetty 9 at this point. The question is how can we get users onto a stable deployment pattern on Jetty 10. A very small number of users are affected by this problem, and I suspect if pings aren't making it through within 2 minutes that those users have other problems with networking and/or CPU saturation impacting networking. But ultimately this timeout is configurable, so there should be a guaranteed workaround for anyone affected: just set the timeout to an extremely high value (e.g. 86,400,000 milliseconds which is 24 hours).

  10. jenkins-infra-bot commented on Nov 11, 2022

    @jenkins-infra-bot
    Author
    jenkinsivo:
    • Original comment link
    • Raw content of original comment:

      we have the same problem, the connection stops at some point and returns a "channel is already closed" message.

      we have already tried to solve this on our own, in vain. It would be nice if this got a little more attention.

    we have the same problem, the connection stops at some point and returns a "channel is already closed" message.

    we have already tried to solve this on our own, in vain. It would be nice if this got a little more attention.

  11. jenkins-infra-bot commented on Nov 11, 2022

    @jenkins-infra-bot
    Author
    basil:

    It would be nice if this got a little more attention.

    jenkinsivo It would be nice if you could read JENKINS-69955 (comment).

  12. jenkins-infra-bot commented on Nov 15, 2022

    @jenkins-infra-bot
    Author
    sbc8112:
    • Original comment link
    • Raw content of original comment:

      I have tried to update to v2.377 and add the --httpKeepAliveTimeout=120000 but the abnormal disconnect happened in hours. I will try to downgrade to v2.346 and check if this can help.

      As same as gyu test, there is no connection issue on v2.346..

    I have tried to update to v2.377 and add the --httpKeepAliveTimeout=120000 but the abnormal disconnect happened in hours. I will try to downgrade to v2.346 and check if this can help.

    As same as gyu test, there is no connection issue on v2.346..

  13. jenkins-infra-bot commented on Nov 15, 2022

    @jenkins-infra-bot
    Author
    basil:
    • Original comment link
    • Raw content of original comment:

      And same as my reply to George Yu, I have to reiterate that downgrading to 2.346 is an exercise in futility compared to applying the workaround I described previously.

    And same as my reply to George Yu, I have to reiterate that downgrading to 2.346 is an exercise in futility compared to applying the workaround I described previously.

  14. jenkins-infra-bot commented on Nov 15, 2022

    @jenkins-infra-bot
    Author
    jenkinsivo:
    • Original comment link
    • Raw content of original comment:

      We have added the keepalive in the config yesterday to 30 seconds, but the error still occurs afterwards, so 86400000 is the next step. to be continued.

      I'm not going to downgrade immediately, that's a version from May this year, then we're going very far back in time.

    We have added the keepalive in the config yesterday to 30 seconds, but the error still occurs afterwards, so 86400000 is the next step. to be continued.

    I'm not going to downgrade immediately, that's a version from May this year, then we're going very far back in time.

  15. jenkins-infra-bot commented on Nov 17, 2022

    @jenkins-infra-bot
    Author
    jenkinsivo:
    • Original comment link
    • Raw content of original comment:

      the keepalive is set to 86400000 but it looks like the issue still occurs unfortunately. any other suggestions? we prefer not to downgrade basil 

    the keepalive is set to 86400000 but it looks like the issue still occurs unfortunately. any other suggestions? we prefer not to downgrade basil 

  16. 16 remaining items

  17. jenkins-infra-bot commented on Feb 22, 2023

    @jenkins-infra-bot
    Author
    olamy:
    idle timeout check, elapsed: 30003 ms, remaining: -3 ms 

    really possible reason. Jetty have a default IdleTime out 30s.

    websocket is sending ping per default every 30s. (see https://github.com/jenkinsci/jenkins/blob/a3f31145e621ab0072bb872ecac93a2c6cbcbaae/core/src/main/java/jenkins/websocket/WebSocketSession.java#L58)

    so yup this ping can work or not work by a matter of few milliseconds (in this logs it's 3ms) it depends on the network and if you are lucky or not  

    possible workaround start jenkins master with

     -Djenkins.websocket.pingInterval=15

    ping delay will be shorter than Jetty idle timeout.

    Change the configuration of Jetty websocket container to have a  larger per default idle timeout.

    can be done around here

    req.setAttribute(ATTR_LISTENER, listener);

    with something such

    JettyWebSocketServerContainer.getContainer(req.getServletContext()).setIdleTimeout(some duration); 

     

    Javadoc from here https://github.com/eclipse/jetty.project/blob/b7075161d015ddce23fbf3db873d5f6b539f6a6b/jetty-io/src/main/java/org/eclipse/jetty/io/IdleTimeout.java#L29

    a check is then made to see when the last operation took place. 

    so if nothing happen during 30s in the established websocket connection.... 

  18. jenkins-infra-bot commented on Feb 22, 2023

    @jenkins-infra-bot
    Author
    allan_burdajewicz:

    I can definitely reproduce with 2.361.1 by adjusting the websocket ping interval. And I can't reproduce with 2.346.4.
    Updated the description with a reproduction scenario.

    IIUC the previous websocket timeout was 5 minutes. Set by the WebsocketPolicy at https://github.com/eclipse/jetty.project/blob/jetty-9.4.48.v20220622/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketPolicy.java#L81-L86

  19. jenkins-infra-bot commented on Feb 28, 2023

    @jenkins-infra-bot
    Author
    leminhhung0110:
    • Original comment link
    • Raw content of original comment:

      allan_burdajewicz Hi Allan, could you have some updates or workaround on this issue?

      Currently, i'm using Jenkins 2.375.1 and due to some reason I could not rollback to jenkins 2.346.3 LTS as suggestion above. 

    allan_burdajewicz Hi Allan, could you have some updates or workaround on this issue?

    Currently, i'm using Jenkins 2.375.1 and due to some reason I could not rollback to jenkins 2.346.3 LTS as suggestion above. 

  20. jenkins-infra-bot commented on Feb 28, 2023

    @jenkins-infra-bot
    Author
    olamy:
    • Original comment link
    • Raw content of original comment:

      leminhhung0110  this a PR ready. Currently you can use the workaround  -Djenkins.websocket.pingInterval=15 or even less

    leminhhung0110  this a PR ready. Currently you can use the workaround 
    -Djenkins.websocket.pingInterval=15
    or even less

  21. jenkins-infra-bot commented on Feb 28, 2023

    @jenkins-infra-bot
    Author
    leminhhung0110:
    • Original comment link
    • Raw content of original comment:

      olamy do you meant i will use this command when starting jenkins master "jenkins restart -Djenkins.websocket.pingInterval=15"?

    olamy do you meant i will use this command when starting jenkins master "jenkins restart -Djenkins.websocket.pingInterval=15"?

  22. jenkins-infra-bot commented on Mar 1, 2023

    @jenkins-infra-bot
    Author
    olamy:
    • Original comment link
    • Raw content of original comment:

      leminhhung0110 I have no idea what your script called jenkins is doing   but Jenkins need to be started with the system property.

    leminhhung0110 I have no idea what your script called jenkins is doing   but Jenkins need to be started with the system property.

  23. jenkins-infra-bot commented on Nov 24, 2025

    @jenkins-infra-bot
    Author

    [Original relates_to from Jira: JENKINS-70697]

  24. removed
    bugFor changelog: Minor bug. Will be listed after features
    on Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions