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

Faye (1.2.4) does not work with jruby-9.2.0.0 #502

Open
MoMoneyRiches opened this issue Aug 16, 2018 · 2 comments
Open

Faye (1.2.4) does not work with jruby-9.2.0.0 #502

MoMoneyRiches opened this issue Aug 16, 2018 · 2 comments

Comments

@MoMoneyRiches
Copy link

MoMoneyRiches commented Aug 16, 2018

I've tried using the following simple ruby code on jruby-9.2.0.0 to authenticate with salesforce via Restforce(3.0.1) gem then try to subscribe to a push topic and it doesn't work and I get an error. See the steps to reproduce below with my expected behavior and actual behavior.

Note if needed I can add steps for the "Streaming API Developer Guide" part. Or maybe change to use another streaming api like twitter to make the repo more easier.

Steps to reproduce:

  1. Use jruby-9.2.0.0
  2. Install Restforce(3.0.1), faye (1.2.4), & pry (0.11.3 java)
  3. Follow Streaming API Developer Guide - Quick Start Using Workbench
  4. Use the follow ruby code in pry
require 'faye'
require 'eventmachine'
require 'restforce'

url = "https://na31.salesforce.com/cometd/36.0"

restforce = Restforce.new(
                  api_version: '36.0',
                  username: 'username,
                  password: 'password',
                  client_id: 'clientid',
                  client_secret: 'clientsecret')

authorization_hash = restforce.authenticate!

client = Faye::Client.new(url)
client.set_header('Authorization', "OAuth #{authorization_hash.access_token}")

EM.run {
	client.subscribe('/topic/AllAccounts') do |message|
		puts message
	end
}
  1. Trigger an action to trigger the push notification

Expected:
{"event"=>{"createdDate"=>"2018-08-16T20:27:28.818Z", "replayId"=>41, "type"=>"created"}, "sobject"=>{"Id"=>"0013700000ZQWB9AAP", "Name"=>"asdf"}}

Actual:
ArgumentError: Invalid header value type
from org/ruby_http_parser/RubyHttpParser.java:478:in `header_value_type='

Notes:
If I repeat the steps above but use ruby 2.5.1 and it works fine. Would be happy to debug this but I'm still a novice for ruby. Also not sure if this is the proper place to put this bug. I'm also a novice to github.

Logger
I, [2018-08-16T19:45:39.934649 #74015] INFO -- : [Faye::Client] Initiating handshake with "https://na31.salesforce.com/cometd/36.0"
D, [2018-08-16T19:45:40.021247 #74015] DEBUG -- : [Faye::Dispatcher] Selected "long-polling" transport for https://na31.salesforce.com/cometd/36.0
D, [2018-08-16T19:45:40.034068 #74015] DEBUG -- : [Faye::Client] Passing through outgoing extensions: {"channel":"/meta/handshake","version":"1.0","supportedConnectionTypes":["in-process","websocket","long-polling"],"id":"1"}
D, [2018-08-16T19:45:40.035476 #74015] DEBUG -- : [Faye::Transport::Http] Client nil sending message to https://na31.salesforce.com/cometd/36.0 via "long-polling": {"channel":"/meta/handshake","version":"1.0","supportedConnectionTypes":["in-process","websocket","long-polling"],"id":"1"}
ArgumentError: Invalid header value type
from org/ruby_http_parser/RubyHttpParser.java:478:in `header_value_type='

Stacktrace
ArgumentError: Invalid header value type
header_value_type= at org/ruby_http_parser/RubyHttpParser.java:478
post_init at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:115
block in activate_connection at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:58
bind_connect at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/eventmachine-1.2.7-java/lib/eventmachine.rb:686
activate_connection at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:55
setup_request at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:92
post at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:8
create_request at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/faye-1.2.4/lib/faye/transport/http.rb:70
request at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/faye-1.2.4/lib/faye/transport/http.rb:15
flush at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/faye-1.2.4/lib/faye/transport/transport.rb:82
block in publish at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/faye-1.2.4/lib/faye/transport/transport.rb:68
block in add_timeout at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/faye-1.2.4/lib/faye/mixins/timeouts.rb:9
event_callback at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/eventmachine-1.2.7-java/lib/eventmachine.rb:1545
eventCallback at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/eventmachine-1.2.7-java/lib/jeventmachine.rb:105
run_machine at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/eventmachine-1.2.7-java/lib/jeventmachine.rb:124
run at /Users/mislam/.rbenv/versions/jruby-9.2.0.0/lib/ruby/gems/shared/gems/eventmachine-1.2.7-java/lib/eventmachine.rb:195

@jcoglan
Copy link
Collaborator

jcoglan commented Jun 11, 2019

I've managed to narrow this down to an issue in http_parser.rb's Java code, and I've opened a pull request for it: tmm1/http_parser.rb#63

Unfortunately I've not managed to find a workaround using monkey-patching to amend the affected method, as it requires changing the native code which we don't have access to at runtime.

@jcoglan
Copy link
Collaborator

jcoglan commented Jun 11, 2019

In the meantime, em-http-request continues to work on all recent MRI Ruby versions, and we also have a Node.js version of Faye, if you need an alternative way of connecting to the Salesforce API.

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