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

failed to reach server #19

Closed
schepens83 opened this issue Mar 8, 2021 · 13 comments
Closed

failed to reach server #19

schepens83 opened this issue Mar 8, 2021 · 13 comments

Comments

@schepens83
Copy link

Expected Behavior

=> hola

=> cómo estás

Actual Behavior

Traceback (most recent call last):
9: from translate.rb:12:in <main>' 8: from translate.rb:12:in each'
7: from translate.rb:13:in block in <main>' 6: from /home/sander/.rvm/gems/ruby-2.7.0/gems/tr4n5l4te-0.1.9/lib/tr4n5l4te/translator.rb:20:in translate'
5: from /home/sander/.rvm/gems/ruby-2.7.0/gems/tr4n5l4te-0.1.9/lib/tr4n5l4te/translator.rb:58:in smart_visit' 4: from /home/sander/.rvm/gems/ruby-2.7.0/gems/tr4n5l4te-0.1.9/lib/tr4n5l4te/agent.rb:75:in visit'
3: from /home/sander/.rvm/gems/ruby-2.7.0/gems/capybara-2.18.0/lib/capybara/session.rb:274:in visit' 2: from /home/sander/.rvm/gems/ruby-2.7.0/gems/poltergeist-1.18.1/lib/capybara/poltergeist/driver.rb:100:in visit'
1: from /home/sander/.rvm/gems/ruby-2.7.0/gems/poltergeist-1.18.1/lib/capybara/poltergeist/browser.rb:39:in visit' /home/sander/.rvm/gems/ruby-2.7.0/gems/poltergeist-1.18.1/lib/capybara/poltergeist/browser.rb:396:in command': Request to 'https://translate.google.com/#en/es/hello' failed to reach server, check DNS and/or server status (Capybara::Poltergeist::StatusFailError)

Steps to reproduce the problem

bundle init, and added your gem. bundle install. created translate.rb:

require 'rubygems'
require 'bundler/setup'

# require your gems as usual
require 'tr4n5l4te'

translator = Tr4n5l4te::Translator.new
english_strings = %w(
  hello
  how are you
)
english_strings.each do |text|
  puts translator.translate(text, :en, :es)
end

ruby translate.rb


  • Current Version:
  • Operating System: Ubuntu
@midwire
Copy link
Owner

midwire commented Mar 9, 2021

@schepens83 - I tried your code and did not receive the same error. I'm guessing you possibly have a DNS or network issue. If you try to ping translate.google.com does that get resolved to an IP address?

I am seeing a different error:

Capybara::ElementNotFound: Unable to find css ".tlid-translation"

But this is due to Google changing the interface for the translation tool. Hopefully there will be an easy way to accommodate their changes.

Let me know about the network/DNS thing.

@midwire
Copy link
Owner

midwire commented Mar 9, 2021

Something I also noticed in your code:

english_strings = %w(
  hello
  how are you
)

When you use %w, embedded spaces in strings are lost and each word becomes a separate string (or element in the array). so your english_strings array will look like this:

=> ["hello", "how", "are", "you"]

You'll probably want to do something like this:

english_strings = [
  'hello',
  'how are you'
]

which will give you:

=> ["hello", "how are you"]

@midwire midwire mentioned this issue Mar 9, 2021
2 tasks
@midwire
Copy link
Owner

midwire commented Mar 9, 2021

The changes to the translator web interface are now accommodated with PR #21

@midwire
Copy link
Owner

midwire commented Mar 9, 2021

Closing this issue as I believe it is local DNS or network related.

@midwire midwire closed this as completed Mar 9, 2021
@schepens83
Copy link
Author

Hi Midwire

Indeed strange. If I ping https://translate.google.com it doesn't know the service. If i paste it in the browser it just works. If I ping translate.google.com it does work. Similar for other websites - if I put https:// in front it doesnt work from the terminal.

@midwire
Copy link
Owner

midwire commented Mar 11, 2021

Ping won't resolve a URL with the http(s) schema in front of the hostname. But if you can ping translate.google.com then the gem command should work. Are you behind a corporate firewall or NAT?

@midwire midwire reopened this Mar 11, 2021
@midwire
Copy link
Owner

midwire commented Mar 11, 2021

You can also try this curl https://translate.google.com/#en/es/hello if you have curl installed. If that fails it points to a network or DNS issue.

@schepens83
Copy link
Author

I'm at home. Not any firewall or NAT that I'm aware of.
curl works for me

@schepens83
Copy link
Author

Ah followed this https://serverfault.com/questions/502668/check-for-firewall-nat-on-network
and indeed I'm behind a NAT. Any way around this issue then?

@midwire
Copy link
Owner

midwire commented Mar 11, 2021

curl works for me

Well, that makes it interesting then. This is the first time anyone has reported this kind of issue, and if that curl command works, the gem should work.

There is another open Issue #18 which requests proxy support. That may help you as well.

Let me research a bit.

@midwire
Copy link
Owner

midwire commented Mar 11, 2021

@schepens83 your NAT should be OK, but it seems like you may be using some kind of proxy (socks5 or http). After doing some research, I can reproduce your issue if I configure a proxy. Unfortunately there is not an easy way for me to tell if you are using one. You can search for "determine if you are using a proxy" in your search engine of choice to see if that helps making the determination.

PhantomJS can be very finicky about proxies, which is why I've not gotten a working branch with proxy usage yet.

Ultimately if you find you are using a proxy and can disable it, you should be able to use tr4n5l4te.

This issue is most definitely network-related and not code-related.

Let me know if I can help further.

@schepens83
Copy link
Author

schepens83 commented Mar 11, 2021

@midwire yes thanks. I think that's the case. I share my internet with my parents next door and pass 2 routers to the internet. Probably this. I'll set it up on a server and should work then. thanks for the effort.

@midwire
Copy link
Owner

midwire commented Mar 11, 2021

You are welcome. 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants