Repository navigation
Issue with ruby 2.4.0 #683
Description
Activity
Interesting. StubSocket does have close method defined.
Would you mind providing a sample code to reproduce the issue?
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) endHope that helps in reproducing the error and fixing this issue.
@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?
Reacted by Kanstantsin Ilchanka, Drew Stephens, Stan Bright, Holger Frohloff, Robert Pankowecki, kaiba, Robert Głód, Chad Wilken, Brian Cain, Lucas Moulin and 8 more@bblimke Thanks for your prompt response. I am updating my gem and will share the spec run results here.
@bblimke Updating webmock gem from 2.1.0 to version 2.3.2 fixed the mentioned error in comment #683 (comment).
Thanks a lot!
Reacted by Robert PankoweckiI was also using WebMock 2.1.0 with ruby 2.4
Just upgraded to WebMock 2.3.2 and everything is fine.
Thanks
Reacted by Chris Thomson, Stan Bright, Michael Miller, Emmanuel Delgado and Haris- added a commit that references this issue
on Sep 23, 2017 - added 2 commits that reference this issue
on Nov 22, 2017 - added 2 commits that reference this issue
on Nov 30, 2017 - added a commit that references this issue
on Jul 15, 2018 13 remaining items
- added a commit that references this issue
on Mar 18, 2020 - added a commit that references this issue
on Mar 19, 2020 - added 2 commits that reference this issue
on Apr 23, 2020 - added 3 commits that reference this issue
on Jul 16, 2020 - added a commit that references this issue
on Jul 28, 2021 - added a commit that references this issue
on Sep 19, 2023 - added 2 commits that reference this issue
on Nov 18, 2023
I am facing following error with ruby 2.4.0, It works fine with 2.3.3
The line causing is simply a Net::HTTP.post_form