いつもお世話になっております。
スクレイピングを行うプログラムで下記のログのように外部接続を行うとサーバーがプログラムを拒否してしまい途中でプログラムが止まってしまいます。
/usr/local/rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:882:in `rescue in block in connect': Failed to open TCP connection to 127.0.0.1:8910 (Connection refused - connect(2) for "127.0.0.1" port 8910) (Errno::ECONNREFUSED) from /usr/local/rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:879:in `block in connect' from /usr/local/rbenv/versions/2.3.1/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout' from /usr/local/rbenv/versions/2.3.1/lib/ruby/2.3.0/timeout.rb:101:in `timeout' from /usr/local/rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:878:in `connect' from /usr/local/rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:863:in `do_start' from /usr/local/rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:852:in `start' from /usr/local/rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:584:in `start' from /var/www/html/Ruby/Application/ReviewList/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/common/service.rb:93:in `connect_to_server' from /var/www/html/Ruby/Application/ReviewList/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/common/service.rb:116:in `stop_server' from /var/www/html/Ruby/Application/ReviewList/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/common/service.rb:79:in `stop' from /var/www/html/Ruby/Application/ReviewList/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/common/service.rb:69:in `block in start' from /var/www/html/Ruby/Application/ReviewList/vendor/bundle/ruby/2.3.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/common/platform.rb:138:in `block in exit_hook
ログにもあるTCP 8910ですが、リッスンされておりませんでした。
他に8910で被っているプロセスも見つかりませんでした。
tcp 0 0 0.0.0.0:8911 0.0.0.0:* LISTEN 4442/phantomjs tcp 0 0 0.0.0.0:8912 0.0.0.0:* LISTEN 7428/phantomjs
###iptables
Chain INPUT (policy ACCEPT) target prot opt source destination f2b-dovecot-pop3imap tcp -- anywhere anywhere multiport dports pop3,imap f2b-SSH tcp -- anywhere anywhere tcp dpt:ssh RH-Firewall-1-INPUT all -- anywhere anywhere ACCEPT tcp -- anywhere anywhere tcp dpt:hbci ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:telnet Chain FORWARD (policy ACCEPT) target prot opt source destination RH-Firewall-1-INPUT all -- anywhere anywhere Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain RH-Firewall-1-INPUT (2 references) target prot opt source destination ACCEPT all -- anywhere anywhere ACCEPT icmp -- anywhere anywhere icmp any ACCEPT esp -- anywhere anywhere ACCEPT ah -- anywhere anywhere ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns ACCEPT udp -- anywhere anywhere udp dpt:ipp ACCEPT tcp -- anywhere anywhere tcp dpt:ipp ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:10022 ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:https ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:smtp ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:urd ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:submission ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:pop3 ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:pop3s ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:imap ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:imaps REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain f2b-SSH (1 references) target prot opt source destination RETURN all -- anywhere anywhere Chain f2b-dovecot-pop3imap (1 references) target prot opt source destination RETURN all -- anywhere anywhere
###気になる点
接続を拒否されているタイミングは、初回の接続ではなくアクセスしてしばらくしてからになります。webサイトの3ページ目ぐらいでアクセスが拒否され止まっています。
何かプロセスが動的に拒否しているのではないかと考えているのですが、関係あるのでしょうか?
###質問
この問題の際でプログラムが全滅してしまい大変困っております。どなたでもいいので怪しい部分があればご指摘お願い致します。
###環境
CentOS6
Ruby
Selenium
PhantomJS
VPS
回答2件
あなたの回答
tips
プレビュー