* Tramp timeout for currently unreachable connections?
@ 2024-09-12 14:32 Visuwesh
2024-09-12 14:47 ` Michael Albinus
0 siblings, 1 reply; 10+ messages in thread
From: Visuwesh @ 2024-09-12 14:32 UTC (permalink / raw)
To: help-gnu-emacs
Hello all,
I know that non-essential=t prevents Tramp from establishing new
connections but is there a way to make Tramp use a very short timeout
when trying to connect to a previously established connection that is
now unreachable? What I mean is: if I am connected to a remote host via
a ssh connection /ssh:user@remote: and my internet connection goes down,
I do not want Tramp trying to fetch remote resources forever. For
example, consider an abbreviate-file-name call when such a connection is
no longer reachable. With M-x toggle-debug-on-quit,
M-: (let ((non-essential t) (remote-file-name-access-timeout 1)) (abbreviate-file-name default-directory)) RET ... C-g
in a remote buffer yields the following backtrace:
Debugger entered--Lisp error: (quit "")
signal(quit (""))
tramp-signal-hook-function(quit nil)
tramp-accept-process-output(#<process *tramp/ssh user@remote*>)
tramp-wait-for-regexp(#<process *tramp/ssh user@remote*> nil "\\(?:^\\|\0\\)\\(?:[^\n#$]*///4a90d21f6648cee2bec7823f4b91fec3#\\$\\(?:\33\\[[0-?]*[ -/]*[@-~]\\)?\15?$\\)")
tramp-wait-for-output(#<process *tramp/ssh user@remote*>)
tramp-send-command((tramp-file-name "ssh" "user" nil "remote" nil "/home/user/tmp" nil) "test -e /home/user/tmp 2>/dev/null; echo tramp_exit_status $?")
tramp-send-command-and-check((tramp-file-name "ssh" "user" nil "remote" nil "/home/user/tmp" nil) "test -e /home/user/tmp")
tramp-sh-handle-file-exists-p("/ssh:user@remote:/home/user/tmp")
apply(tramp-sh-handle-file-exists-p "/ssh:user@remote:/home/user/tmp")
tramp-sh-file-name-handler(file-exists-p "/ssh:user@remote:/home/user/tmp")
apply(tramp-sh-file-name-handler file-exists-p "/ssh:user@remote:/home/user/tmp")
tramp-file-name-handler(file-exists-p "/ssh:user@remote:/home/user/tmp")
file-exists-p("/ssh:user@remote:/home/user/tmp")
tramp-handle-file-name-case-insensitive-p("/ssh:user@remote:/home/user/tmp/")
apply(tramp-handle-file-name-case-insensitive-p "/ssh:user@remote:/home/user/tmp/")
tramp-sh-file-name-handler(file-name-case-insensitive-p "/ssh:user@remote:/home/user/tmp/")
apply(tramp-sh-file-name-handler file-name-case-insensitive-p "/ssh:user@remote:/home/user/tmp/")
tramp-file-name-handler(file-name-case-insensitive-p "/ssh:user@remote:/home/user/tmp/")
file-name-case-insensitive-p("/ssh:user@remote:/home/user/tmp/")
tramp-handle-abbreviate-file-name("/ssh:user@remote:/home/user/tmp/")
apply(tramp-handle-abbreviate-file-name "/ssh:user@remote:/home/user/tmp/")
tramp-sh-file-name-handler(abbreviate-file-name "/ssh:user@remote:/home/user/tmp/")
apply(tramp-sh-file-name-handler abbreviate-file-name "/ssh:user@remote:/home/user/tmp/")
tramp-file-name-handler(abbreviate-file-name "/ssh:user@remote:/home/user/tmp/")
abbreviate-file-name("/ssh:user@remote:/home/user/tmp/")
(let ((non-essential t) (remote-file-name-access-timeout 1)) (abbreviate-file-name default-directory))
eval((let ((non-essential t) (remote-file-name-access-timeout 1)) (abbreviate-file-name default-directory)) t)
#f(compiled-function () #<bytecode -0x93fec5cef4eacc6>)()
#f(compiled-function () #<bytecode -0x5db3e1955cb81d1>)()
handler-bind-1(#f(compiled-function () #<bytecode -0x5db3e1955cb81d1>) (error) eval-expression--debug)
eval-expression((let ((non-essential t) (remote-file-name-access-timeout 1)) (abbreviate-file-name default-directory)) nil nil 127)
funcall-interactively(eval-expression (let ((non-essential t) (remote-file-name-access-timeout 1)) (abbreviate-file-name default-directory)) nil nil 127)
call-interactively(eval-expression nil nil)
command-execute(eval-expression)
I would like to know if it is possible to make Tramp send non-nil
TIMEOUT argument to tramp-wait-for-output (maybe even higher up the
call chain). I know of without-remote-files but is there a less heavier
hammer? Because I do _want_ Tramp to do its job when the connection is
still reachable.
Thank you.
P.S. Kindly keep me CC'd since I do not follow this list.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tramp timeout for currently unreachable connections?
2024-09-12 14:32 Tramp timeout for currently unreachable connections? Visuwesh
@ 2024-09-12 14:47 ` Michael Albinus
2024-09-12 15:24 ` Visuwesh
2024-09-12 15:27 ` Robert Pluim
0 siblings, 2 replies; 10+ messages in thread
From: Michael Albinus @ 2024-09-12 14:47 UTC (permalink / raw)
To: Visuwesh; +Cc: help-gnu-emacs
Visuwesh <visuweshm@gmail.com> writes:
> Hello all,
Hi Visuwesh,
> I know that non-essential=t prevents Tramp from establishing new
> connections but is there a way to make Tramp use a very short timeout
> when trying to connect to a previously established connection that is
> now unreachable? What I mean is: if I am connected to a remote host via
> a ssh connection /ssh:user@remote: and my internet connection goes down,
> I do not want Tramp trying to fetch remote resources forever.
Use 'M-x tramp-cleanup-connection'. Play with user option `tramp-connection-timeout'.
> Thank you.
Best regards, Michael.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tramp timeout for currently unreachable connections?
2024-09-12 14:47 ` Michael Albinus
@ 2024-09-12 15:24 ` Visuwesh
2024-09-12 17:27 ` Michael Albinus
2024-09-12 15:27 ` Robert Pluim
1 sibling, 1 reply; 10+ messages in thread
From: Visuwesh @ 2024-09-12 15:24 UTC (permalink / raw)
To: Michael Albinus; +Cc: help-gnu-emacs
[வியாழன் செப்டம்பர் 12, 2024] Michael Albinus wrote:
> Visuwesh <visuweshm@gmail.com> writes:
>
>> Hello all,
>
> Hi Visuwesh,
Hello Michael,
>> I know that non-essential=t prevents Tramp from establishing new
>> connections but is there a way to make Tramp use a very short timeout
>> when trying to connect to a previously established connection that is
>> now unreachable? What I mean is: if I am connected to a remote host via
>> a ssh connection /ssh:user@remote: and my internet connection goes down,
>> I do not want Tramp trying to fetch remote resources forever.
>
> Use 'M-x tramp-cleanup-connection'.
I can always C-g and execute this command but I would like to do it
automagically in my lisp programs so, unfortunately, this isn't exactly
an option. Half the time, I forget the freezes are due to Tramp
inability to speak with the remote machine too...
> Play with user option `tramp-connection-timeout'.
If I let-bind tramp-connection-timeout to 1 in the above example, Tramp
still tries to talk with the remote machine. :-( Am I misunderstanding
your suggestion? Should I be using with-(tramp-)timeout?
>> Thank you.
>
> Best regards, Michael.
Thank you for your answers.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tramp timeout for currently unreachable connections?
2024-09-12 14:47 ` Michael Albinus
2024-09-12 15:24 ` Visuwesh
@ 2024-09-12 15:27 ` Robert Pluim
2024-09-12 17:14 ` Visuwesh
2024-09-12 17:22 ` Michael Albinus
1 sibling, 2 replies; 10+ messages in thread
From: Robert Pluim @ 2024-09-12 15:27 UTC (permalink / raw)
To: Michael Albinus; +Cc: Visuwesh, help-gnu-emacs
>>>>> On Thu, 12 Sep 2024 16:47:39 +0200, Michael Albinus <michael.albinus@gmx.de> said:
Michael> Visuwesh <visuweshm@gmail.com> writes:
>> Hello all,
Michael> Hi Visuwesh,
>> I know that non-essential=t prevents Tramp from establishing new
>> connections but is there a way to make Tramp use a very short timeout
>> when trying to connect to a previously established connection that is
>> now unreachable? What I mean is: if I am connected to a remote host via
>> a ssh connection /ssh:user@remote: and my internet connection goes down,
>> I do not want Tramp trying to fetch remote resources forever.
Michael> Use 'M-x tramp-cleanup-connection'. Play with user option `tramp-connection-timeout'.
Idle thought: would enabling 'ServerAliveInterval' help at all here?
(my Tramp connections travel from one side of my desk to the other, so
I canʼt tell ☺️)
Robert
--
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tramp timeout for currently unreachable connections?
2024-09-12 15:27 ` Robert Pluim
@ 2024-09-12 17:14 ` Visuwesh
2024-09-12 17:37 ` Michael Albinus
2024-09-12 17:22 ` Michael Albinus
1 sibling, 1 reply; 10+ messages in thread
From: Visuwesh @ 2024-09-12 17:14 UTC (permalink / raw)
To: Robert Pluim; +Cc: Michael Albinus, help-gnu-emacs
[வியாழன் செப்டம்பர் 12, 2024] Robert Pluim wrote:
>>>>>> On Thu, 12 Sep 2024 16:47:39 +0200, Michael Albinus <michael.albinus@gmx.de> said:
>
> Michael> Visuwesh <visuweshm@gmail.com> writes:
> >> Hello all,
>
> Michael> Hi Visuwesh,
>
> >> I know that non-essential=t prevents Tramp from establishing new
> >> connections but is there a way to make Tramp use a very short timeout
> >> when trying to connect to a previously established connection that is
> >> now unreachable? What I mean is: if I am connected to a remote host via
> >> a ssh connection /ssh:user@remote: and my internet connection goes down,
> >> I do not want Tramp trying to fetch remote resources forever.
>
> Michael> Use 'M-x tramp-cleanup-connection'. Play with user option `tramp-connection-timeout'.
>
> Idle thought: would enabling 'ServerAliveInterval' help at all here?
> (my Tramp connections travel from one side of my desk to the other, so
> I canʼt tell ☺️)
I have it set to 100 but it doesn't help much. I don't think I am
describing my problem well. I have the following function
(defun vz/stb--buffer-annotation (buffer)
(let ((case-fold-search nil))
(pcase (buffer-name buffer)
((rx bos (1+ anychar) "<" (+ (not ">")) ">")
(let ((non-essential t))
(vz/with-when (buffer-file-name buffer)
(abbreviate-file-name it)))
;; (let ((non-essential t))
;; (vz/with-when (vz/file-visiting-buffer-p buffer)
;; (abbreviate-file-name it)))
)
((rx bos "*" (or "shell" "ssh") (? "-"))
(let ((non-essential t))
(abbreviate-file-name (buffer-local-value 'default-directory buffer))))
(_ (vz/buffer-annotation buffer)))))
that returns an annotation string for my C-x b replacement. If Tramp
already knows the connection is dead, non-essential=t signals Tramp to
not to bother to open a new connection. I would like a similar variable
to make Tramp give up after a few seconds if it gets no reply from the
remote server in the case of connections that are no longer reachable.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tramp timeout for currently unreachable connections?
2024-09-12 15:27 ` Robert Pluim
2024-09-12 17:14 ` Visuwesh
@ 2024-09-12 17:22 ` Michael Albinus
2024-09-12 17:35 ` Visuwesh
1 sibling, 1 reply; 10+ messages in thread
From: Michael Albinus @ 2024-09-12 17:22 UTC (permalink / raw)
To: Robert Pluim; +Cc: Visuwesh, help-gnu-emacs
Robert Pluim <rpluim@gmail.com> writes:
Hi Robert,
>>>>>> On Thu, 12 Sep 2024 16:47:39 +0200, Michael Albinus <michael.albinus@gmx.de> said:
>
> Michael> Visuwesh <visuweshm@gmail.com> writes:
> >> Hello all,
>
> Michael> Hi Visuwesh,
>
> >> I know that non-essential=t prevents Tramp from establishing new
> >> connections but is there a way to make Tramp use a very short timeout
> >> when trying to connect to a previously established connection that is
> >> now unreachable? What I mean is: if I am connected to a remote host via
> >> a ssh connection /ssh:user@remote: and my internet connection goes down,
> >> I do not want Tramp trying to fetch remote resources forever.
>
> Michael> Use 'M-x tramp-cleanup-connection'. Play with user option `tramp-connection-timeout'.
>
> Idle thought: would enabling 'ServerAliveInterval' help at all here?
> (my Tramp connections travel from one side of my desk to the other, so
> I canʼt tell ☺️)
Yes, even the Tramp manual speaks about:
--8<---------------cut here---------------start------------->8---
4.19.2 Detection of session hangouts
------------------------------------
‘ssh’ sessions on the local host hang when the network is down. TRAMP
cannot safely detect such hangs. OpenSSH can be configured to kill
such hangs with the following settings in ‘~/.ssh/config’:
Host *
ServerAliveInterval 5
ServerAliveCountMax 2
--8<---------------cut here---------------end--------------->8---
But who reads manuals ...
> Robert
Best regards, Michael.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tramp timeout for currently unreachable connections?
2024-09-12 15:24 ` Visuwesh
@ 2024-09-12 17:27 ` Michael Albinus
0 siblings, 0 replies; 10+ messages in thread
From: Michael Albinus @ 2024-09-12 17:27 UTC (permalink / raw)
To: Visuwesh; +Cc: help-gnu-emacs
Visuwesh <visuweshm@gmail.com> writes:
> Hello Michael,
Hi Visuwesh,
>>> I know that non-essential=t prevents Tramp from establishing new
>>> connections but is there a way to make Tramp use a very short timeout
>>> when trying to connect to a previously established connection that is
>>> now unreachable? What I mean is: if I am connected to a remote host via
>>> a ssh connection /ssh:user@remote: and my internet connection goes down,
>>> I do not want Tramp trying to fetch remote resources forever.
>>
>> Use 'M-x tramp-cleanup-connection'.
>
> I can always C-g and execute this command but I would like to do it
> automagically in my lisp programs so, unfortunately, this isn't exactly
> an option. Half the time, I forget the freezes are due to Tramp
> inability to speak with the remote machine too...
Ah, I thought you're speaking about the interactive case.
>> Play with user option `tramp-connection-timeout'.
>
> If I let-bind tramp-connection-timeout to 1 in the above example, Tramp
> still tries to talk with the remote machine. :-( Am I misunderstanding
> your suggestion? Should I be using with-(tramp-)timeout?
tramp-connection-timeout is of help only for establishing a new
connection. That's why I've mentioned it, in conjuntion with
tramp-cleanup-connection.
> Thank you for your answers.
Best regards, Michael.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tramp timeout for currently unreachable connections?
2024-09-12 17:22 ` Michael Albinus
@ 2024-09-12 17:35 ` Visuwesh
0 siblings, 0 replies; 10+ messages in thread
From: Visuwesh @ 2024-09-12 17:35 UTC (permalink / raw)
To: Michael Albinus; +Cc: Robert Pluim, help-gnu-emacs
[வியாழன் செப்டம்பர் 12, 2024] Michael Albinus wrote:
> Robert Pluim <rpluim@gmail.com> writes:
>
> Hi Robert,
>
>>>>>>> On Thu, 12 Sep 2024 16:47:39 +0200, Michael Albinus <michael.albinus@gmx.de> said:
>>
>> Michael> Visuwesh <visuweshm@gmail.com> writes:
>> >> Hello all,
>>
>> Michael> Hi Visuwesh,
>>
>> >> I know that non-essential=t prevents Tramp from establishing new
>> >> connections but is there a way to make Tramp use a very short timeout
>> >> when trying to connect to a previously established connection that is
>> >> now unreachable? What I mean is: if I am connected to a remote host via
>> >> a ssh connection /ssh:user@remote: and my internet connection goes down,
>> >> I do not want Tramp trying to fetch remote resources forever.
>>
>> Michael> Use 'M-x tramp-cleanup-connection'. Play with user option `tramp-connection-timeout'.
>>
>> Idle thought: would enabling 'ServerAliveInterval' help at all here?
>> (my Tramp connections travel from one side of my desk to the other, so
>> I canʼt tell ☺️)
>
> Yes, even the Tramp manual speaks about:
>
> 4.19.2 Detection of session hangouts
> ------------------------------------
>
> ‘ssh’ sessions on the local host hang when the network is down. TRAMP
> cannot safely detect such hangs. OpenSSH can be configured to kill
> such hangs with the following settings in ‘~/.ssh/config’:
>
> Host *
> ServerAliveInterval 5
> ServerAliveCountMax 2
>
> But who reads manuals ...
Ahh!! It seems I completely misunderstood these two variables in my
initial reading of ssh_config(5) when I was initially reading through
the Tramp manual. Thank you for pointing this out again.
>> Robert
>
> Best regards, Michael.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tramp timeout for currently unreachable connections?
2024-09-12 17:14 ` Visuwesh
@ 2024-09-12 17:37 ` Michael Albinus
2024-09-12 17:45 ` Visuwesh
0 siblings, 1 reply; 10+ messages in thread
From: Michael Albinus @ 2024-09-12 17:37 UTC (permalink / raw)
To: Visuwesh; +Cc: Robert Pluim, help-gnu-emacs
Visuwesh <visuweshm@gmail.com> writes:
Hi Visuwesh,
>> Idle thought: would enabling 'ServerAliveInterval' help at all here?
>> (my Tramp connections travel from one side of my desk to the other, so
>> I canʼt tell ☺️)
> I have it set to 100 but it doesn't help much. I don't think I am
> describing my problem well. I have the following function
>
> (defun vz/stb--buffer-annotation (buffer)
> (let ((case-fold-search nil))
> (pcase (buffer-name buffer)
> ((rx bos (1+ anychar) "<" (+ (not ">")) ">")
> (let ((non-essential t))
> (vz/with-when (buffer-file-name buffer)
> (abbreviate-file-name it)))
> ;; (let ((non-essential t))
> ;; (vz/with-when (vz/file-visiting-buffer-p buffer)
> ;; (abbreviate-file-name it)))
> )
> ((rx bos "*" (or "shell" "ssh") (? "-"))
> (let ((non-essential t))
> (abbreviate-file-name (buffer-local-value 'default-directory buffer))))
> (_ (vz/buffer-annotation buffer)))))
>
> that returns an annotation string for my C-x b replacement. If Tramp
> already knows the connection is dead, non-essential=t signals Tramp to
> not to bother to open a new connection. I would like a similar variable
> to make Tramp give up after a few seconds if it gets no reply from the
> remote server in the case of connections that are no longer reachable.
I've quoted the Tramp manual in my answer to Robert: "‘ssh’ sessions on
the local host hang when the network is down. TRAMP cannot safely
detect such hangs."
The reason is, that Tramp just sees a server, which doesn't respond to a
request. It doesn't know the reason for that non-responsiveness. The
request could be, for example, to copy a file of dozens or hundreds MBs
(yes, I've seen this in the wild). This can take a long time, and it
would be intended by the user. There is no good timeout value to stop
waiting the the response.
Best regards, Michael.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Tramp timeout for currently unreachable connections?
2024-09-12 17:37 ` Michael Albinus
@ 2024-09-12 17:45 ` Visuwesh
0 siblings, 0 replies; 10+ messages in thread
From: Visuwesh @ 2024-09-12 17:45 UTC (permalink / raw)
To: Michael Albinus; +Cc: Robert Pluim, help-gnu-emacs
[வியாழன் செப்டம்பர் 12, 2024] Michael Albinus wrote:
> Visuwesh <visuweshm@gmail.com> writes:
>
> Hi Visuwesh,
>
>>> Idle thought: would enabling 'ServerAliveInterval' help at all here?
>>> (my Tramp connections travel from one side of my desk to the other, so
>>> I canʼt tell ☺️)
>
>> I have it set to 100 but it doesn't help much. I don't think I am
>> describing my problem well. I have the following function
>>
>> (defun vz/stb--buffer-annotation (buffer)
>> (let ((case-fold-search nil))
>> (pcase (buffer-name buffer)
>> ((rx bos (1+ anychar) "<" (+ (not ">")) ">")
>> (let ((non-essential t))
>> (vz/with-when (buffer-file-name buffer)
>> (abbreviate-file-name it)))
>> ;; (let ((non-essential t))
>> ;; (vz/with-when (vz/file-visiting-buffer-p buffer)
>> ;; (abbreviate-file-name it)))
>> )
>> ((rx bos "*" (or "shell" "ssh") (? "-"))
>> (let ((non-essential t))
>> (abbreviate-file-name (buffer-local-value 'default-directory buffer))))
>> (_ (vz/buffer-annotation buffer)))))
>>
>> that returns an annotation string for my C-x b replacement. If Tramp
>> already knows the connection is dead, non-essential=t signals Tramp to
>> not to bother to open a new connection. I would like a similar variable
>> to make Tramp give up after a few seconds if it gets no reply from the
>> remote server in the case of connections that are no longer reachable.
>
> I've quoted the Tramp manual in my answer to Robert: "‘ssh’ sessions on
> the local host hang when the network is down. TRAMP cannot safely
> detect such hangs."
>
> The reason is, that Tramp just sees a server, which doesn't respond to a
> request. It doesn't know the reason for that non-responsiveness. The
> request could be, for example, to copy a file of dozens or hundreds MBs
> (yes, I've seen this in the wild). This can take a long time, and it
> would be intended by the user. There is no good timeout value to stop
> waiting the the response.
Thanks, so the only realistic option is to adjust those ssh variables to
a sensible value then. I was under the impression that there existed a
variable or function that would force Tramp to use a specific timeout
value but in retrospect, I see that it would be unreliable. Thank you
once again for pointing to the manual making me realise my initial
misunderstanding of the ssh variables.
> Best regards, Michael.
Thank you for your patience in answering my questions!
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-09-12 17:45 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-12 14:32 Tramp timeout for currently unreachable connections? Visuwesh
2024-09-12 14:47 ` Michael Albinus
2024-09-12 15:24 ` Visuwesh
2024-09-12 17:27 ` Michael Albinus
2024-09-12 15:27 ` Robert Pluim
2024-09-12 17:14 ` Visuwesh
2024-09-12 17:37 ` Michael Albinus
2024-09-12 17:45 ` Visuwesh
2024-09-12 17:22 ` Michael Albinus
2024-09-12 17:35 ` Visuwesh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).