Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listener only listens on/connects to 127.0.0.1 (localhost) #245

Closed
mechanicalduck opened this issue Aug 1, 2014 · 0 comments · Fixed by #255
Closed

Listener only listens on/connects to 127.0.0.1 (localhost) #245

mechanicalduck opened this issue Aug 1, 2014 · 0 comments · Fixed by #255
Labels

Comments

@mechanicalduck
Copy link

Guard use case:
I use guard and guard/listen to watch a mounted remote file system (samba using CIFS)
where CIFS unfortunately doesn't support inotify (and probably also would not in the future)
albeit samba itself does.

On system where the shared files are local, guard/listen is run in forwarding mode
and on the peers which should be informed about changes, guard is run
with --listen-on to listen on the sharing system.

Issue:
Letting listen daemon forward to 127.0.0.1 and listening on 127.0.0.1 works
(although it wouldn't really make sense except for debugging)..
However, when a remote address of the machine is used for forwarding,
listening on it doesn't work anymore, no notifications are received.

Debugging in pry indicates that listen.start() got stuck
and never returns (in contrast to listening to 127.0.0.1) (see further below).

Test was done on the same system (to eliminate interference with samba, etc):

  • Debian Wheezy amd64
  • 192.168.100.120 on eth0 (usual LAN)
  • ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux].
  • guard (2.6.1)
  • listen (2.7.9)

On daemon:
$ listen --forward=192.168.100.120:4000 --verbose

Starting listen...
> ["/test/testfile"]   <-- File change is provoked after first connecting the peer to it (see below)

On peer:
test.rb:

require 'listen'

listener = Listen.on '192.168.100.120:4000' do |modified, added, removed|
  print 'change'
end

listener.start
sleep
ruby test.rb

Nothing is printed after file notification on daemon
(using 127.0.0.1 in contrast works and 'change' is printed.)

But telnet can properly receive the notifications (interestingly they are send in plaintext by the way):
$ telnet 192.168.100.120 4000

Trying 192.168.100.120 ...
Connected to 192.168.100.120 .
Escape character is '^]'.
K["file","modified","/test","testfile",{}]

(Note to the fellow debugger: Terminate the telnet session with key combination Ctrl-+)

$ pry
[1] pry(main)> require 'listen'
=> true
[2] pry(main)> listener = Listen.on '192.168.100.120:4000' do |modified, added, removed|
[2] pry(main)*   print 'change'
[2] pry(main)* end
=> #<Listen::Listener:0x007f9bfaed3170
 @block=#<Proc:0x007f9bfaed3288@(pry):2>,
 @directories=[],
 @host="192.168.100.120",
 @options={:debug=>false, :latency=>nil, :wait_for_delay=>0.1, :force_polling=>false, :polling_fallback_message=>nil, :force_tcp=>true},
 @port=4000,
 @queue=#<Thread::Queue:0x007f9bfac2b5d0>,
 @registry=#<Celluloid::Registry:0x007f9bfac2b468 @registry={}, @registry_lock=#<Mutex:0x007f9bfac2b3c8>>,
 @silencer=
  #<Listen::Silencer:0x007f9bfaed2d60
   @ignore_patterns=
    [/^(?:
      \.git
      | \.svn
      | \.hg
      | \.rbx
      | \.bundle
      | bundle
      | vendor\/bundle
      | log
      | tmp
      |vendor\/ruby
    )(\/|$)/x,
     /(?:
      # Kate's tmp\/swp files
      \..*\d+\.new
      | \.kate-swp

      # Gedit tmp files
      | \.goutputstream-.{6}

      # Intellij files
      | ___jb_bak___
      | ___jb_old___

      # Vim swap files and write test
      | \.sw[px]
      | \.swpx
      | ^4913

      # other files
      | \.DS_Store
      | \.tmp
      | ~
    )$/x],
   @only_patterns=nil>,
 @state=:stopped,
 @tcp_mode=:recipient>
[3] pry(main)> listener.start

After listener.start, execution hangs.
In contrast, using 127.0.0.1 would result in a normal return.

So listening on 127.0.0.1 works, listening on remote does not,
while telnet can receive the notifications in both cases, on 127.0.0.1 and on remote.

With best regards

@mechanicalduck mechanicalduck changed the title Listener only listens on/connects to 127.0.0.1 (localhsot) Listener only listens on/connects to 127.0.0.1 (localhost) Aug 1, 2014
@e2 e2 closed this as completed in #255 Sep 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants