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

Issue with ruby 2.4.0 #683

Closed
lokenmakwana opened this issue Feb 8, 2017 · 6 comments
Closed

Issue with ruby 2.4.0 #683

lokenmakwana opened this issue Feb 8, 2017 · 6 comments

Comments

@lokenmakwana
Copy link

I am facing following error with ruby 2.4.0, It works fine with 2.3.3

NoMethodError: undefined method `close' for #<StubSocket:0x007f871cf99070>
Did you mean?  closed?
               clone

The line causing is simply a Net::HTTP.post_form

@bblimke
Copy link
Owner

bblimke commented Feb 10, 2017

Interesting. StubSocket does have close method defined.

Would you mind providing a sample code to reproduce the issue?

@jiggneshhgohel
Copy link

I am also facing the same error after upgrading Ruby from version 2.3.2 to 2.4.0 in my Rails 5.0.0.1 application. My spec examples fails with the same error:

Failure/Error: response = http_client.post(json_payload) # json_payload because request's Content-Type is application/json.
      
      NoMethodError:
        undefined method `close' for #<StubSocket:0x0000000c8c3488>
        Did you mean?  closed?
                       clone

      # /home/jignesh/.rvm/gems/ruby-2.4.0@my_app-rails-5/gems/webmock-2.1.0/lib/webmock/http_lib_adapters/net_http.rb:125:in `start_without_connect'
      # /home/jignesh/.rvm/gems/ruby-2.4.0@my_app-rails-5/gems/webmock-2.1.0/lib/webmock/http_lib_adapters/net_http.rb:150:in `start'
      # /home/jignesh/.rvm/gems/ruby-2.4.0@my_app-rails-5/gems/rest-client-2.0.0/lib/restclient/request.rb:766:in `transmit'
      # /home/jignesh/.rvm/gems/ruby-2.4.0@my_app-rails-5/gems/rest-client-2.0.0/lib/restclient/request.rb:215:in `execute'
      # /home/jignesh/.rvm/gems/ruby-2.4.0@my_app-rails-5/gems/rest-client-2.0.0/lib/restclient/request.rb:52:in `execute'
      # /home/jignesh/.rvm/gems/ruby-2.4.0@my_app-rails-5/gems/rest-client-2.0.0/lib/restclient/resource.rb:67:in `post'
      # ./app/utils/notifications/notification_mode/push_notification.rb:285:in `send_push_notification_request'
...
....
...

Below is the relevant code-snippet

      def send_push_notification_request(payload)
        begin
          json_payload = payload.to_json
          response = http_client.post(json_payload) # json_payload because request's Content-Type is application/json.
        rescue RestClient::Exception => rce
          response = rce.response
        end

        response_status = response.code
        Rails.logger.info "Push Notification Response Status: #{response_status}"

        is_push_delivered = (APPERY_PUSH_NOTIFICATION_SEND_API_SUCCESS_STATUS == response_status)

        unless is_push_delivered
          response_body = response.body.empty? ? "{}" : response.body
          json_hash = JSON.parse(response_body)
          error_message = json_hash["description"]
          error_code = json_hash["code"]
          Rails.logger.warn(">>>>>>>> Could not deliver push notification to device(uid: #{payload[:filter][:deviceID]}). Appery Push Notification API responded with error: '#{error_message}' and error code: '#{error_code}'")
        end

        is_push_delivered
      end

      def http_client
        @http_client ||= RestClient::Resource.new(request_url, headers: request_headers)
      end

Hope that helps in reproducing the error and fixing this issue.

@bblimke
Copy link
Owner

bblimke commented Feb 15, 2017

@jiggneshhgohel I can see you are using WebMock 2.1.0

Support for ruby 2.4.0 has been added in WebMock 2.3.1

@lokenmakwana what version of webmock do you use?

@jiggneshhgohel
Copy link

@bblimke Thanks for your prompt response. I am updating my gem and will share the spec run results here.

@jiggneshhgohel
Copy link

@bblimke Updating webmock gem from 2.1.0 to version 2.3.2 fixed the mentioned error in comment #683 (comment).

Thanks a lot!

@lokenmakwana
Copy link
Author

I was also using WebMock 2.1.0 with ruby 2.4

Just upgraded to WebMock 2.3.2 and everything is fine.

Thanks

hannahwhy added a commit to hannahwhy/mastodon that referenced this issue Apr 9, 2017
Modified gems:

- json was updated because json 1.8.3 contained references to Bignum and
  Fixnum, which no longer exist in Ruby 2.4.
- For webmock: bblimke/webmock#683
mshenfield pushed a commit to mshenfield/CutePets that referenced this issue Sep 23, 2017
Closes codeforamerica#58. 2.4.2 is the latest version of ruby [supported by Heroku](https://devcenter.heroku.com/articles/ruby-support#supported-runtimes). The current version is causing deploys of this app to Heroku to fail.

This also updates various dependencies in the lockfile using `bundle update #{name}` because of issues related to newer versions of ruby.

- `json` [⚠](ruby/json#286)
- `safe_yaml` [⚠](dtao/safe_yaml#67)
- `webmock` [⚠] (bblimke/webmock#683)

For folks that have this checked out locally, I also had to `brew install --force` to force an up to date build of `http_parse.rb`, which was throwing `Symbol not found: _rb_cFixnum`.

Finally, this updates petharbor cassette to include URL encoded quotes - this is probably just an internal change to `URI.encode_www_form`.
RoryMacDonald pushed a commit to alphagov/calculators that referenced this issue Nov 22, 2017
RoryMacDonald pushed a commit to alphagov/calendars that referenced this issue Nov 22, 2017
sj26 added a commit to sj26/cronitor that referenced this issue Nov 30, 2017
I got lots of this:

  1) Cronitor sets its config correctly has the specified options
     Failure/Error:
       response = Unirest.get(
         "#{API_URL}/monitors/#{URI.escape(name).gsub('[', '%5B').gsub(']', '%5D')}",
         headers: default_headers,
         auth: { user: token }
       )

     NoMethodError:
       undefined method `close' for #<StubSocket:0x007f8de75d28a8>
     # ./lib/cronitor.rb:46:in `exists?'
     # ./lib/cronitor.rb:27:in `initialize'
     # ./spec/cronitor_spec.rb:17:in `new'
     # ./spec/cronitor_spec.rb:17:in `block (3 levels) in <top (required)>'
     # ./spec/cronitor_spec.rb:25:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # RestClient::ResourceNotFound:
     #   404 Resource Not Found
     #   ./lib/cronitor.rb:46:in `exists?'

Seems to be this issue which is fixed in webmock >= 2.3.1:

bblimke/webmock#683

Simply updating seems to work fine.
sj26 added a commit to sj26/cronitor that referenced this issue Nov 30, 2017
I got lots of this:

  1) Cronitor sets its config correctly has the specified options
     Failure/Error:
       response = Unirest.get(
         "#{API_URL}/monitors/#{URI.escape(name).gsub('[', '%5B').gsub(']', '%5D')}",
         headers: default_headers,
         auth: { user: token }
       )

     NoMethodError:
       undefined method `close' for #<StubSocket:0x007f8de75d28a8>
     # ./lib/cronitor.rb:46:in `exists?'
     # ./lib/cronitor.rb:27:in `initialize'
     # ./spec/cronitor_spec.rb:17:in `new'
     # ./spec/cronitor_spec.rb:17:in `block (3 levels) in <top (required)>'
     # ./spec/cronitor_spec.rb:25:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # RestClient::ResourceNotFound:
     #   404 Resource Not Found
     #   ./lib/cronitor.rb:46:in `exists?'

Seems to be this issue which is fixed in webmock >= 2.3.1:

bblimke/webmock#683

Simply updating seems to work fine.
DevinDow added a commit to DevinDow/edX-Ruby-2-hw-sinatra-saas-hangperson that referenced this issue Jul 15, 2018
myersjustinc added a commit to associatedpress/bls_api that referenced this issue Aug 15, 2018
To include Ruby 2.4 support:
bblimke/webmock#683
chrismytton added a commit to theyworkforyou/shineyoureye-sinatra that referenced this issue Oct 9, 2018
The current version of Ruby, 2.3.1, is "In security maintenance phase
(will EOL soon!)", so upgrade to the newest available stable version of
Ruby.

I had to update Webmock as well because the version we were on is
incompatible with Ruby >= 2.4 [1]

[1]: bblimke/webmock#683
chrismytton added a commit to theyworkforyou/shineyoureye-sinatra that referenced this issue Oct 9, 2018
The current version of Ruby, 2.3.1, is "In security maintenance phase
(will EOL soon!)", so upgrade to the newest available stable version of
Ruby.

I had to update Webmock as well because the version we were on is
incompatible with Ruby >= 2.4 [1]

[1]: bblimke/webmock#683
chrismytton added a commit to theyworkforyou/shineyoureye-sinatra that referenced this issue Oct 9, 2018
The current version of Ruby, 2.3.1, is "In security maintenance phase
(will EOL soon!)", so upgrade to the newest available stable version of
Ruby.

I had to update Webmock as well because the version we were on is
incompatible with Ruby >= 2.4 [1]

The change in `bin/build_summaries.rb` was prompted by a new Rubocop
warning when I switched the target version to 2.5.

[1]: bblimke/webmock#683
chrismytton added a commit to theyworkforyou/shineyoureye-sinatra that referenced this issue Nov 28, 2018
The current version of Ruby, 2.3.1, is "In security maintenance phase
(will EOL soon!)", so upgrade to the newest available stable version of
Ruby.

I had to update Webmock as well because the version we were on is
incompatible with Ruby >= 2.4 [1]

The change in `bin/build_summaries.rb` was prompted by a new Rubocop
warning when I switched the target version to 2.5.

[1]: bblimke/webmock#683
chrismytton added a commit to theyworkforyou/shineyoureye-sinatra that referenced this issue Nov 29, 2018
The current version of Ruby, 2.3.1, is "In security maintenance phase
(will EOL soon!)", so upgrade to the newest available stable version of
Ruby.

I had to update Webmock as well because the version we were on is
incompatible with Ruby >= 2.4 [1]

The change in `bin/build_summaries.rb` was prompted by a new Rubocop
warning when I switched the target version to 2.5.

[1]: bblimke/webmock#683
MarcoBgn added a commit to moneyadviceservice/azure-activedirectory-library-for-ruby that referenced this issue Jan 28, 2019
- Bumping to Ruby 2.5.3 and running specs generated:
  NoMethodError: undefined method `close' for #<StubSocket:0x007f871cf99070>
  Did you mean?  closed?
                 clone

  This turned ut to be Webmock, that had to be bumped > 2.3.2
  see: bblimke/webmock#683
danschmidt5189 added a commit to danschmidt5189/omniauth-cas that referenced this issue Feb 14, 2019
Requires updating webmock; see: bblimke/webmock#683
danschmidt5189 added a commit to dlindahl/omniauth-cas that referenced this issue Feb 15, 2019
Requires updating webmock; see: bblimke/webmock#683
dsantosmerino added a commit to Badiapp/geokit that referenced this issue Oct 6, 2019
It fixes some compatibility issues with Ruby v2.4. Source: bblimke/webmock#683.
janis-vitols added a commit to mitigate-dev/omniauth-azure-activedirectory that referenced this issue Mar 18, 2020
Problem:
  When running unit tests received undefined method error
  <NoMethodError: undefined method `close' for #<StubSocket:0x007fbacd90ee28>

Solution:
  Update `webmock` based on bblimke/webmock#683
bittersweet added a commit to Springest/vat_check that referenced this issue Mar 19, 2020
d-m-u added a commit to d-m-u/faraday_middleware that referenced this issue Apr 1, 2020
olleolleolle pushed a commit to lostisland/faraday_middleware that referenced this issue Apr 1, 2020
dezande pushed a commit to jobteaser/omniauth-cas that referenced this issue Apr 23, 2020
Requires updating webmock; see: bblimke/webmock#683
dezande pushed a commit to jobteaser/omniauth-cas that referenced this issue Apr 24, 2020
Requires updating webmock; see: bblimke/webmock#683
amro pushed a commit to amro/gibbon that referenced this issue May 1, 2020
The version of WebMock used has issues with Ruby 2.4+ (although for some
reason this hasn't come up on Travis until now) - c.f.
bblimke/webmock#683

- Bump `webmock` gem to latest version
- Change `stub_request` calls to use new basic auth syntax introduced
  with WebMock 2.0
leesharma added a commit to leesharma/rescuetime that referenced this issue Jun 13, 2020
Resolves #29

The listed version of webmock did not support ruby 2.4, so this path
upgrades to the minimum compatible version (~> 2.3.1).

See bblimke/webmock#683
joshcooper added a commit to joshcooper/puppet that referenced this issue Jul 16, 2020
Webmock added support for ruby 2.3.1 but the Socket#close method was not
stubbed which causes integration test errors if the connection is closed.
See bblimke/webmock#683.

Bump webmock to at least 2.3.2, but less than 3, since 3 requires ruby 2.0
joshcooper added a commit to joshcooper/puppet that referenced this issue Jul 16, 2020
Webmock added support for ruby 2.3.1 but the Socket#close method was not
stubbed which causes integration test errors if the connection is closed.
See bblimke/webmock#683.

Bump webmock to at least 2.3.2, but less than 3, since 3 requires ruby 2.0.

Also bump vcr to a compatible versions to avoid tests trying to resolve
DNS for bogus hostnames.
joshcooper added a commit to joshcooper/puppet that referenced this issue Jul 22, 2020
Webmock added support for ruby 2.3.1 but the Socket#close method was not
stubbed which causes integration test errors if the connection is closed.
See bblimke/webmock#683.

Bump webmock to at least 2.3.2, but less than 3, since 3 requires ruby 2.0.

Also bump vcr to a compatible versions to avoid tests trying to resolve
DNS for bogus hostnames.
mdudzinski added a commit to asmallworldsite/emarsys-rb that referenced this issue Aug 13, 2020
The webmock versions below 2.3.1 do not support ruby 2.4.0 and higher.
Please see bblimke/webmock#683 for more
details.
dsantosmerino added a commit to Badiapp/geokit that referenced this issue Jul 28, 2021
It fixes some compatibility issues with Ruby v2.4. Source: bblimke/webmock#683.
redconfetti pushed a commit to sis-berkeley-edu/omniauth-cas that referenced this issue Sep 19, 2023
redconfetti pushed a commit to sis-berkeley-edu/omniauth-cas that referenced this issue Nov 18, 2023
redconfetti pushed a commit to sis-berkeley-edu/omniauth-cas that referenced this issue Nov 18, 2023
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

3 participants