function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chirag MehtaChirag Mehta 

java.net.ProtocolException: Unexpected response 401: TransportExchange

I'm trying to build the "JavaClientExample" as described @ http://wiki.developerforce.com/index.php/Getting_Started_with_the_Force.com_Streaming_API

 

I am able to successfully connect to salesforce, but post that I get following error: (Any idea or help will be really appreciated)

Waiting for handshake
2011-10-20 11:29:24.779:INFO:org.cometd.client.BayeuxClient@229902:
java.net.ProtocolException: Unexpected response 401: TransportExchange@21375057=POST//na1.salesforce.com:443/cometd/handshake#7
	at org.cometd.client.BayeuxClient$PublishTransportListener.onProtocolError(BayeuxClient.java:969)
	at org.cometd.client.transport.LongPollingTransport$TransportExchange.onResponseComplete(LongPollingTransport.java:291)
	at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:920)
	at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:263)
	at org.eclipse.jetty.client.HttpConnection$Handler.messageComplete(HttpConnection.java:622)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:862)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:214)
	at org.eclipse.jetty.client.HttpConnection.handle(HttpConnection.java:269)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:515)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)
	at java.lang.Thread.run(Unknown Source)

 

Best Answer chosen by Admin (Salesforce Developers) 
sgurumurthysgurumurthy

Changed the following lines in the original Java client code to get it up and running: 

 

1. API version on the end point: 

    private static final String DEFAULT_PUSH_ENDPOINT = "/cometd/23.0";

2. Added '/topic/' to channel: 

        client.getChannel("/topic/" + topic).subscribe(new MessageListener() {

3. Change to include token as OAuth authorization header instead of cookie: 

-         final String sid = response.getString("access_token"); //Changed to final

-        LongPollingTransport transport = new LongPollingTransport(

        options, httpClient) {

        @Override

        protected void customize(ContentExchange exchange) {

        super.customize(exchange);

        exchange.addRequestHeader("Authorization", "OAuth " + sid);

        }

        };

/*        BayeuxClient client = new BayeuxClient(instance_url

                + DEFAULT_PUSH_ENDPOINT, new LongPollingTransport(

                options, httpClient));

        client.setCookie("sid", sid, 24 * 60 * 60 * 1000);*/

        BayeuxClient client = new BayeuxClient(instance_url + DEFAULT_PUSH_ENDPOINT, transport);

All Answers

KevinG514KevinG514

I'm running into the same problem.  I had a working program the last time i worked on it, which was during Dreamforce.  I returned to it today and now I'm getting the same error. 

VM_SFDCVM_SFDC

Can you send us your orgids? Also, please provide login access so that we can examine your org.

 

Thanks!

Vinod.

KevinG514KevinG514

org: 00DA0000000H0K7

 

access granted.  Thanks

Chirag MehtaChirag Mehta

Organization ID 00D300000006hMb

Access granted to "Salesforce Support" for One Week.

 

Let me know if anything else is required.

VM_SFDCVM_SFDC

Chirag, I used your sessionid to connect to streaming API and I was able to connect fine.I created few records in your org and I was able to see the streamed events.

 

Please make sure you have:

 

    private static final String CHANNEL = "/topic/AllAccounts";
    private static final String STREAMING_ENDPOINT_URI = "/cometd/23.0";

 

Also make sure the sessionId you are using is valid. To validate it go to: 

 

https://na1.salesforce.com/soap/ajax/23.0/debugshell.html

 

set:

 

sforce.connection.sessionId = ".... <your sessionid> ...."

sforce.connection.getUserInfo(); -> this should give you the right output. If it fails with INVALID_SESSION_ID then your sessionid is not valid.

VM_SFDCVM_SFDC

Kevin, I tried your org as well. I was able to connect just fine:

 

Running streaming client example....
Login successful!
Endpoint: https://<>.salesforce.com
Sessionid=.....
Waiting for handshake
[CHANNEL:META_HANDSHAKE]: {"id":"1","minimumVersion":"1.0","supportedConnectionTypes":["long-polling"],"successful":true,"channel":"/meta/handshake","clientId":"...........","version":"1.0"}
[CHANNEL:META_CONNECT]: {"id":"2","successful":true,"advice":{"interval":0,"reconnect":"retry","timeout":110000},"channel":"/meta/connect"}
Subscribing for channel: /topic/CaseQueued
Waiting for streamed data from salesforce ...
[CHANNEL:META_SUBSCRIBE]: {"id":"4","subscription":"/topic/CaseQueued","successful":true,"channel":"/meta/subscribe"}
[CHANNEL:META_CONNECT]: {"id":"3","successful":true,"channel":"/meta/connect"}


Please make sure the sessionid that is generated after login is valid (using the debug shell perhaps).

KevinG514KevinG514

I can connect fine also using workbench, just can't in my java app.

 

I remember something was mentioned at dreamforce about some uri changing with this in winter 12.  So it must have been the endpoint and topic.  The java example on the wiki still has the old way to connect where the endpoint is just /cometd and the channel is just "/topicname"  

http://wiki.developerforce.com/index.php/JavaClientExample.java

 

 

VM_SFDCVM_SFDC

This JavaClientExample is outdated. Apologies for the confusion. We'll have it updated soon.

 

Here is the latest doc:

 

http://www.salesforce.com/us/developer/docs/api_streaming/index.htm

http://www.salesforce.com/us/developer/docs/api_streaming/api_streaming.pdf

 

The release notes are here: https://eu1.salesforce.com/help/doc/en/salesforce_winter12_release_notes.pdf


(page#103)

 

There are 3 important changes that you need to be aware of:

 

1. The sessionid / oauth token now needs to go with the Authorization header, instead of cookies (example: Authorization: OAuth <sessionId>)

2. API version is now required in the URL: example: https://instance.salesforce.com/cometd/23.0

3. topic names are now prefixed with "/topic" (example: /topic/AllAccounts)

 

 

sgurumurthysgurumurthy

Changed the following lines in the original Java client code to get it up and running: 

 

1. API version on the end point: 

    private static final String DEFAULT_PUSH_ENDPOINT = "/cometd/23.0";

2. Added '/topic/' to channel: 

        client.getChannel("/topic/" + topic).subscribe(new MessageListener() {

3. Change to include token as OAuth authorization header instead of cookie: 

-         final String sid = response.getString("access_token"); //Changed to final

-        LongPollingTransport transport = new LongPollingTransport(

        options, httpClient) {

        @Override

        protected void customize(ContentExchange exchange) {

        super.customize(exchange);

        exchange.addRequestHeader("Authorization", "OAuth " + sid);

        }

        };

/*        BayeuxClient client = new BayeuxClient(instance_url

                + DEFAULT_PUSH_ENDPOINT, new LongPollingTransport(

                options, httpClient));

        client.setCookie("sid", sid, 24 * 60 * 60 * 1000);*/

        BayeuxClient client = new BayeuxClient(instance_url + DEFAULT_PUSH_ENDPOINT, transport);

This was selected as the best answer
Chirag MehtaChirag Mehta

Thanks a lot @VM_SFDC / @sgurumurthy. Finally the streaming worked for me.

 

To add more (@sgurumurthy : I had hard time executing 3rd point due to illegal characters, override annotation and few other things. For ease, below is the function that needs to be updated)

 

    private static BayeuxClient getClient() throws Exception {
        // Authenticate via OAuth
        JSONObject response = oauthLogin();
        System.out.println("Login response: " + response.toString(2));
        if (!response.has("access_token")) {
            throw new Exception("OAuth failed: " + response.toString());
        }

        final String sid = response.getString("access_token"); //Changed to final
        final String instance_url = response.getString("instance_url");        
        
        // Set up a Jetty HTTP client to use with CometD
        HttpClient httpClient = new HttpClient();
        httpClient.setConnectTimeout(TIMEOUT);
        httpClient.setTimeout(TIMEOUT);
        httpClient.start();        
        
        Map<String, Object> options = new HashMap<String, Object>();
        options.put(ClientTransport.TIMEOUT_OPTION, TIMEOUT);        
      
        LongPollingTransport transport = new LongPollingTransport(options,httpClient) {
        	protected void customize(ContentExchange exchange) {
            	super.customize(exchange);
                exchange.addRequestHeader("Authorization", "OAuth " + sid);
            }
        };
        
        BayeuxClient client = new BayeuxClient(instance_url + DEFAULT_PUSH_ENDPOINT, transport);        
        return client;
    }
Pat PattersonPat Patterson

For the record - I just updated the Getting Started with the Force.com Streaming API article to reflect the changes in the Winter '12 release.

 

Cheers,

 

Pat



Chirag MehtaChirag Mehta

Seems the changes aren't saved -:)

 

The page says 

There is currently no text in this page. You can search for this page title in other pages, search the related logs, or edit this page.

 

Pat PattersonPat Patterson

Oops - looks like some weird characters crept into the link - fixed now. Thanks, Chirag!

Chirag MehtaChirag Mehta

It's my pleasure too. Now it looks great and complete too. Thanks a lot!

KevinG514KevinG514

I got it working again too.  Thanks everyone

Chirag MehtaChirag Mehta
The java program runs perfectly. But when I tried to deploy the same to herok, it results in oauth error: Running example.... Login response: {   "error": "invalid_grant",   "error_description": "authentication failure" } Exception in thread "main" java.lang.Exception: OAuth failed: {"error":"invalid_ grant","error_description":"authentication failure"}         at foo.Main.getClient(Main.java:87)         at foo.Main.main(Main.java:54) Any idea?
sgurumurthysgurumurthy

The message indicates authentication failure. So check if you have any inadvertent changes in any of the data fields. If not, will need to see your code section where the error is thrown. 

 

Regards, 

Shashi

Chirag MehtaChirag Mehta
Same credentails(clientid,server etc..) worked when I execute program loccally, but ot dosent work when I try to execute as heroku app.
Pat PattersonPat Patterson

Hi Chirag,

 

Are you setting up the env variables in Heroku like so:

 

heroku config:add LOGIN_SERVER="https://login.salesforce.com" \
    USERNAME="user@example.com" \
    PASSWORD="password" \
    CLIENT_ID="YOUR_CLIENT_ID" \
    CLIENT_SECRET="YOUR_CLIENT_SECRET"

 

Chirag MehtaChirag Mehta
I didn't knew how to do add env variables to heroku, so I hardcoded them in java program itself. To my know both are same, the one you suggeted is configurable(that's the advantage).
Pat PattersonPat Patterson

IP range restrictions in your org?

Chirag MehtaChirag Mehta
No. It's developer org and I haven't added any restrictions on it. I checked Login History and I don't see anything coming under it i.e., request didn't even reach salesforce (obv its oauth failure, so it wouldn't have reached sfdc).
Chirag MehtaChirag Mehta

I was able to get through. It was a typo (Pls don't shout, humans tend to do mistake :smileyhappy:)

 

@Command Line : (Executed "target\bin\webapp.bat"). Below debug shows that it's executing and waiting for streamed data from force.com to send information on creation of new case. It's working as desired.

Waiting for handshake
Subscribing to topic: OpenCases
Waiting for streamed data from Force.com...

 

 

However after uploading to Heroku and executing it via app url (http://floating-sunrise-3802.herokuapp.com/), it waits but the very next second it crashes out (Below debug is pulled after running "heroku logs" command). Any clue on why it's failing when executed from heroku webapp mode?

2011-11-01T07:30:02+00:00 app[web.1]: Subscribing to topic: OpenCases
2011-11-01T07:30:02+00:00 app[web.1]: Waiting for streamed data from Force.com..
.
2011-11-01T07:31:00+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process
 failed to bind to $PORT within 60 seconds of launch
2011-11-01T07:31:00+00:00 heroku[web.1]: Stopping process with SIGKILL
2011-11-01T07:31:00+00:00 heroku[web.1]: Process exited
2011-11-01T07:31:01+00:00 heroku[web.1]: State changed from starting to crashed
2011-11-01T07:34:51+00:00 heroku[api]: Scale to web=1 by jain.chirag@gmail.com
2011-11-01T07:35:35+00:00 heroku[router]: Error H10 (App crashed) -> GET floatin
g-sunrise-3802.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2011-11-01T07:35:36+00:00 heroku[router]: Error H10 (App crashed) -> GET floatin
g-sunrise-3802.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503
bytes=
2011-11-01T07:35:57+00:00 heroku[router]: Error H10 (App crashed) -> GET floatin
g-sunrise-3802.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2011-11-01T07:35:59+00:00 heroku[router]: Error H10 (App crashed) -> GET floatin
g-sunrise-3802.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503
bytes=

 

 

Chirag MehtaChirag Mehta

Any suggestions on below error?

sgurumurthysgurumurthy

When you configure a Heroku app as a web application, the embedded jetty webserver attempts to bind to a port defined by Heroku. This port number is available on $PORT environment variable. You can see the actual code in Main.java generated by Maven. It appears that something is going wrong here. 

 

My first thought was that you have not defined a Procfile in the root of the application directory. I discounted that because the error indicates it is starting web app. Still, could you verify you have a Procfile in the root of the applicatio directory and it contains following code: web: sh target/bin/webapp. 

Chirag MehtaChirag Mehta

Yes there's already a Procfile in root directory (I created that while creating project). I re-tried everything and it seems I was able to get through the Port error, but (as evil doesnt leave u soon) there's one more error:

 

When i execute heroku run "sh target/bin/SFDC"  where SFDC is my java program, it throws following error:

Running sh target/bin/SFDC attached to terminal...
Error connecting to process

 

And the heroku logs says

 

2011-11-02T16:16:24+00:00 heroku[router]: GET morning-earth-9889.heroku.com/favi
con.ico dyno=web.1 queue=0 wait=1ms service=5ms status=404 bytes=1376
2011-11-02T16:16:28+00:00 app[run.1]: Error R13 (Attach error) -> Failed to atta
ch to process
2011-11-02T16:16:28+00:00 heroku[run.1]: Process exited
2011-11-02T16:17:16+00:00 heroku[run.2]: State changed from starting to up
2011-11-02T16:17:46+00:00 heroku[run.2]: Process exited

 

 

Pat PattersonPat Patterson

How about running the java app directly, with no 'sh' - heroku run target/bin/SFDC

sgurumurthysgurumurthy

There's the problem. The target of sh, i.e. target/bin/SFDC in this case, cannot be a Java class. It has to be a shell script which in turn executes the java program. 

 

For example, in my shell program to run the Main.java program, the last statement in the shell script is as follows. There are many more statements in the shell script before this statement which set up the environment. 

 

exec "$JAVACMD" $JAVA_OPTS \  $EXTRA_JVM_ARGUMENTS \  -classpath "$CLASSPATH" \  -Dapp.name="webapp" \  -Dapp.pid="$$" \  -Dapp.repo="$REPO" \  -Dbasedir="$BASEDIR" \  my.package..Main \  "$@"

 

Hope this makes it clear. 

 

Regards, 

Shashi

Chirag MehtaChirag Mehta

same result :(

 

I executed heroku run  "target/bin/SFDC"

Running target/bin/SFDC attached to terminal...
Error connecting to process

 

And the heroku logs :

2011-11-02T16:39:44+00:00 heroku[run.7]: State changed from up to complete
2011-11-02T16:40:39+00:00 app[run.7]: Error R13 (Attach error) -> Failed to atta
ch to process
2011-11-02T16:41:22+00:00 heroku[run.8]: State changed from starting to up
2011-11-02T16:41:22+00:00 app[run.8]: Awaiting client

 

Chirag MehtaChirag Mehta

SFDC in "target/bin/SFDC" is SFDC.bat and not SFDC java class (which is actually at target/classes/foo/SFDC.class)

sgurumurthysgurumurthy

Can you post the SFDC shell script as well as the SFDC.java files somewhere where I can have a look. 

 

Regards, 

Shashi

Chirag MehtaChirag Mehta

 

Might be if this helps - The SFDC.java program is "Salesforce Steaming API Program, which runs and wait for streamed data from force.com". Can that be an issue?

 

SFDC.bat

@REM ----------------------------------------------------------------------------
@REM Copyright 2001-2004 The Apache Software Foundation.
@REM
@REM Licensed under the Apache License, Version 2.0 (the "License");
@REM you may not use this file except in compliance with the License.
@REM You may obtain a copy of the License at
@REM
@REM      http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing, software
@REM distributed under the License is distributed on an "AS IS" BASIS,
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@REM See the License for the specific language governing permissions and
@REM limitations under the License.
@REM ----------------------------------------------------------------------------
@REM

@echo off

set ERROR_CODE=0

:init
@REM Decide how to startup depending on the version of windows

@REM -- Win98ME
if NOT "%OS%"=="Windows_NT" goto Win9xArg

@REM set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" @setlocal

@REM -- 4NT shell
if "%eval[2+2]" == "4" goto 4NTArgs

@REM -- Regular WinNT shell
set CMD_LINE_ARGS=%*
goto WinNTGetScriptDir

@REM The 4NT Shell from jp software
:4NTArgs
set CMD_LINE_ARGS=%$
goto WinNTGetScriptDir

:Win9xArg
@REM Slurp the command line arguments.  This loop allows for an unlimited number
@REM of arguments (up to the command line limit, anyway).
set CMD_LINE_ARGS=
:Win9xApp
if %1a==a goto Win9xGetScriptDir
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto Win9xApp

:Win9xGetScriptDir
set SAVEDIR=%CD%
%0\
cd %0\..\.. 
set BASEDIR=%CD%
cd %SAVEDIR%
set SAVE_DIR=
goto repoSetup

:WinNTGetScriptDir
set BASEDIR=%~dp0\..

:repoSetup


if "%JAVACMD%"=="" set JAVACMD=java

if "%REPO%"=="" set REPO=%BASEDIR%\repo

set CLASSPATH="%BASEDIR%"\etc;"%REPO%"\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar;"%REPO%"\org\eclipse\jetty\jetty-webapp\7.4.5.v20110725\jetty-webapp-7.4.5.v20110725.jar;"%REPO%"\org\eclipse\jetty\jetty-xml\7.4.5.v20110725\jetty-xml-7.4.5.v20110725.jar;"%REPO%"\org\eclipse\jetty\jetty-servlet\7.4.5.v20110725\jetty-servlet-7.4.5.v20110725.jar;"%REPO%"\org\eclipse\jetty\jetty-security\7.4.5.v20110725\jetty-security-7.4.5.v20110725.jar;"%REPO%"\org\eclipse\jetty\jetty-server\7.4.5.v20110725\jetty-server-7.4.5.v20110725.jar;"%REPO%"\org\eclipse\jetty\jetty-continuation\7.4.5.v20110725\jetty-continuation-7.4.5.v20110725.jar;"%REPO%"\org\mortbay\jetty\jsp-2.1-glassfish\2.1.v20100127\jsp-2.1-glassfish-2.1.v20100127.jar;"%REPO%"\org\eclipse\jdt\core\compiler\ecj\3.5.1\ecj-3.5.1.jar;"%REPO%"\org\mortbay\jetty\jsp-api-2.1-glassfish\2.1.v20100127\jsp-api-2.1-glassfish-2.1.v20100127.jar;"%REPO%"\ant\ant\1.6.5\ant-1.6.5.jar;"%REPO%"\org\cometd\java\bayeux-api\2.2.0\bayeux-api-2.2.0.jar;"%REPO%"\org\cometd\java\cometd-java-client\2.2.0\cometd-java-client-2.2.0.jar;"%REPO%"\org\eclipse\jetty\jetty-util\7.4.0.v20110414\jetty-util-7.4.0.v20110414.jar;"%REPO%"\org\eclipse\jetty\jetty-io\7.4.0.v20110414\jetty-io-7.4.0.v20110414.jar;"%REPO%"\org\eclipse\jetty\jetty-http\7.4.0.v20110414\jetty-http-7.4.0.v20110414.jar;"%REPO%"\org\eclipse\jetty\jetty-client\7.4.0.v20110414\jetty-client-7.4.0.v20110414.jar;"%REPO%"\org\cometd\java\cometd-java-common\2.2.0\cometd-java-common-2.2.0.jar;"%REPO%"\postgresql\postgresql\9.0-801.jdbc4\postgresql-9.0-801.jdbc4.jar;"%REPO%"\foo\helloworld\1.0-SNAPSHOT\helloworld-1.0-SNAPSHOT.jar
set EXTRA_JVM_ARGUMENTS=
goto endInit

@REM Reaching here means variables are defined and arguments have been captured
:endInit

%JAVACMD% %JAVA_OPTS% %EXTRA_JVM_ARGUMENTS% -classpath %CLASSPATH_PREFIX%;%CLASSPATH% -Dapp.name="SFDC" -Dapp.repo="%REPO%" -Dbasedir="%BASEDIR%" foo.SFDC %CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
goto end

:error
if "%OS%"=="Windows_NT" @endlocal
set ERROR_CODE=1

:end
@REM set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" goto endNT

@REM For old DOS remove the set variables from ENV - we assume they were not set
@REM before we started - at least we don't leave any baggage around
set CMD_LINE_ARGS=
goto postExec

:endNT
@endlocal

:postExec

if "%FORCE_EXIT_ON_ERROR%" == "on" (
  if %ERROR_CODE% NEQ 0 exit %ERROR_CODE%
)

exit /B %ERROR_CODE%

 

sgurumurthysgurumurthy

That could be. Essentially the server program needs to run as a daemon process so it is started up as a servlet or application context listener. What the application developer, i.e. you and me, need to do is to write a client program which subscribes to a channel and waits for messages on that channel. Is this what SFDC.java does?

Chirag MehtaChirag Mehta

The SFDC.java is http://wiki.developerforce.com/page/JavaClientExample.java

 

After creating PushTopic in Salesforce (using system log), I tried creating this JAVA application which can subscribe for updates.

 

PS : Salesforce Streaming API uses the Bayeux protocol to make a connection to the Streaming API, subscribing to topics via the long-polling transport over HTTP. 

sgurumurthysgurumurthy

Chirag, it appears to be some Heroku configuration error which we are not able to debug. I would suggest you review the Heroku workbook for Java to make sure you have followed the instructions properly. Then systematically introduce System.out.println in your main method of SFDC.java. If you do not get the first print as well in the Heroku log, then you know that there is a Heroku configuration problem. Good Luck!

 

Regards,

Shashi

Chirag MehtaChirag Mehta

I followed each and every step as mentioned in java heroku book. 

 

SFDC.java is executing without any errors as heroku logs shows following SOP's. But after printing all below it says "Error R13 (Attach error) -> Failed to attach to process" > so this sounds like Heorku is not allowing to run a listener.

 

Running example....
Login response: {
  "access_token": "00Dx00000008t03!AR0AQGjuKpdpiqFYnNHDJ2.GIjcSmBb3Zp0MbfNJR1hnMD9FhwU.8sF3ty4fuQ2R.13c3PN_Lno57qiDfvjzSaOYpFZVWvHM",
  "id": "https://prerellogin.pre.salesforce.com/id/00Dx00000008t03EAA/005x0000000JNgnAAG",
  "instance_url": "https://prerelna1.pre.salesforce.com",
  "issued_at": "1308678916406",
  "signature": "dpQvS25GyXgB3fi2KlvTKHT/cg1KM7AgDn2apNvgkjw="
}
Waiting for handshake
Subscribing to topic: NewAccounts
Waiting for streamed data from salesforce...

 

nnewboldnnewbold

Chirag,

Can you post your Procfile? I believe what's happening is that you're running your app as a web process. In other words, your procfile probably starts your process using something like:

web: sh target/bin/script.sh

 

Web processes are a special process type that expect incoming HTTP traffic. What that means is that you need to bind the process to the port number specified in $PORT. In other words, you need to start a web server as shown in this example: http://devcenter.heroku.com/articles/java

 

Assuming you are using a web process, you have a couple options: 1) Startup a web server that binds to $PORT and run your listener in that process, or 2) use a different process type, such as a worker.

 

A worker process does not expect to handle incoming traffic and you shouldn't see the 'attach to process' error (as far as I know). To use a worker process, replace the `web` in your Procfile with `worker`, e.g.:

worker: sh target/bin/script.sh

 

Then, make sure you scale the processes appropriately. For instance, `heroku scale web=0` and `heroku scale worker=1`.