Can not Create a Cloud Pub/Sub subscription

920 views
Skip to first unread message

Rohit Nigam

unread,
Feb 29, 2016, 5:28:37 PM2/29/16
to Google Cloud Pub/Sub Discussions
Hi 
I am not able to create  a subscription and assign push end point url  given  the topic name  and end point  url. I keep getting this error...

<p>The requested URL <code>/v1/projects%2Fproject-name%2Fsubscriptions%2Ftest_sub</code> was not found on this server. <ins>That’s all we know.</ins>\n"


The code which gets the Pubsub object is

public static Pubsub createPubsubClient(HttpTransport httpTransport,
JsonFactory jsonFactory) throws IOException {

LOG.info("Entered createPubsubClient");
Preconditions.checkNotNull(httpTransport);
Preconditions.checkNotNull(jsonFactory);
GoogleCredential credential = GoogleCredential.getApplicationDefault();
// In some cases, you need to add the scope explicitly.
if (credential.createScopedRequired()) {
credential = credential.createScoped(PubsubScopes.all());
}
LOG.info("Got the credentials createPubsubClient");
// Please use custom HttpRequestInitializer for automatic
// retry upon failures. We provide a simple reference
// implementation in the "Retry Handling" section.
HttpRequestInitializer initializer =
new RetryHttpInitializerWrapper(credential);
return new Pubsub.Builder(httpTransport, jsonFactory, initializer).setApplicationName(APPLICATION_NAME)
.build();
}

and the code which is creating the Subscriber is 

Pubsub pubsub = ServiceAccountConfiguration.createPubsubClient();
PushConfig pushConfig = new PushConfig()
.setPushEndpoint(url);

Subscription subscription = new Subscription()
.setTopic(topicName)
.setPushConfig(pushConfig);
LOG.info("Creating " + subscriberName + "rohit");
pubsub.projects().subscriptions()
.create(subscriberName, subscription)
.execute();

It fails when i call execute().


Any help would be appreciated.
Rohit



Takashi Matsuo

unread,
Feb 29, 2016, 6:17:23 PM2/29/16
to Rohit Nigam, Google Cloud Pub/Sub Discussions
Hi Rohit,

How do you create the subscriberName? I suspect the subscriberName already contains the percent encoded slashes (%7F). What do your logs say?

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/4820be3c-174e-4f22-b586-a35af4bbbd9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rohit Nigam

unread,
Feb 29, 2016, 7:13:03 PM2/29/16
to Google Cloud Pub/Sub Discussions, tanu...@gmail.com
Hi Takashi
The GAE logs shows the error which states the subscriber name 

<p>The requested URL <code>/v1/projects%2Fproject-name%2Fsubscriptions%2Ftest_sub</code> was not found on this server. <ins>That’s all we know.</ins>\n"

The %7F is there in the logs.
Rohit

To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsub...@googlegroups.com.

Rohit Nigam

unread,
Feb 29, 2016, 7:13:32 PM2/29/16
to Google Cloud Pub/Sub Discussions
Hi Takashi
The GAE logs shows the error which states the subscriber name 

<p>The requested URL <code>/v1/projects%2Fproject-name%2Fsubscriptions%2Ftest_sub</code> was not found on this server. <ins>That’s all we know.</ins>\n"

The %7F is there in the logs.
Rohit

Takashi Matsuo

unread,
Feb 29, 2016, 7:22:46 PM2/29/16
to Rohit Nigam, Google Cloud Pub/Sub Discussions

Hi Rohit,

Sorry, I'm talking about the following log:
```
LOG.info("Creating  " + subscriberName + "rohit");
```
What does it say?

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/6c2a17a9-6c16-4bd7-a6d0-252ea1c3699c%40googlegroups.com.

Rohit Nigam

unread,
Feb 29, 2016, 7:32:51 PM2/29/16
to Google Cloud Pub/Sub Discussions, tanu...@gmail.com
It says 


Creating projects/data-pond/subscriptions/test_subrohit

and then i see these errors

com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backend method com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 NOT_FOUND <!DOCTYPE html> <html lang=en> <meta charset=utf-8> <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"> <title>Error 404 (Not Found)!!1</title> <style> *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px} </style> <a href=//www.google.com/><span id=logo aria-label=Google></span></a> <p><b>404.</b> <ins>That’s an error.</ins> <p>The requested URL <code>/v1/projects%2Fproject-name%2Fsubscriptions%2Ftest_sub</code> was not found on this server. <ins>That’s all we know.</ins> at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321) at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1045)
Not sure why it is not prepending this url https://pubsub.googleapis.com/ and trying to look in the same server.

Rohit
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsub...@googlegroups.com.

Takashi Matsuo

unread,
Feb 29, 2016, 7:52:43 PM2/29/16
to Rohit Nigam, Google Cloud Pub/Sub Discussions
Hi Rohit,

It's weird. Which version of the client library are you using? Can you share the reproducible code with me? I'll try to reproduce it. 

To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/5a6a0e02-9a17-40c3-8a63-ca5448fafb63%40googlegroups.com.

Rohit Nigam

unread,
Feb 29, 2016, 8:11:51 PM2/29/16
to Google Cloud Pub/Sub Discussions, tanu...@gmail.com
Hi Takashi
Here is my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>


<groupId>com.x</groupId>
<artifactId>x-webservices</artifactId>
<version>1</version>
<packaging>war</packaging>
<name>x</name>
<properties>
<appengine.app.version>1</appengine.app.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jersey.version>2.5.1</jersey.version>
<guice.version>3.0</guice.version>
<bigtable.version>0.2.2</bigtable.version>
<alpn.jdk7.version>7.1.3.v20150130</alpn.jdk7.version>
<alpn.jdk8.version>8.1.3.v20150130</alpn.jdk8.version>
<hadoop.version>2.4.1</hadoop.version>
<hbase.version>1.1.0</hbase.version>
</properties>

<prerequisites>
<maven>3.1.0</maven>
</prerequisites>

<dependencies>
<!-- Compile/runtime dependencies -->

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-oauth2</artifactId>
<version>v2-rev75-1.19.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.21.0</version>
</dependency>

<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.21.0</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-appengine</artifactId>
<version>1.16.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.19.0</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.30</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-endpoints</artifactId>
<version>1.9.30</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.12.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.14</version>
</dependency>

<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>


<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0-rc1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.0</version>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>${guice.version}</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>${guice.version}</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
<version>${guice.version}</version>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-storage</artifactId>
<version>v1-rev58-1.21.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-guice</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-cloudresourcemanager</artifactId>
<version>v1beta1-rev10-1.21.0</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-cloudbilling</artifactId>
<version>v1-rev5-1.21.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud.bigtable</groupId>
<artifactId>bigtable-hbase-1.1</artifactId>
<version>0.2.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.6.3</version>
</dependency>

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-pubsub</artifactId>
<version>v1-rev8-1.18.0-rc</version>
</dependency>

<dependency>
<groupId>com.google.appengine.tools</groupId>
<artifactId>appengine-gcs-client</artifactId>
<version>RELEASE</version>
</dependency>



<!--<dependency>-->
<!--<groupId>com.google.gcloud</groupId>-->
<!--<artifactId>gcloud-java-storage</artifactId>-->
<!--<version>0.1.3</version>-->
<!--</dependency>-->


<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>1.9.30</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>1.9.30</version>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>staged</id>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>mac</id>
<properties>
<tcnative.classifier>osx-x86_64</tcnative.classifier>
</properties>
</profile>
<profile>
<id>windows</id>
<properties>
<tcnative.classifier>windows-x86_64</tcnative.classifier>
</properties>
</profile>
<profile>
<id>jdk7</id>
<activation>
<jdk>1.7</jdk>
</activation>
<properties>
<alpn.version>${alpn.jdk7.version}</alpn.version>
</properties>
</profile>
<profile>
<id>jdk8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<properties>
<alpn.version>${alpn.jdk8.version}</alpn.version>
</properties>
</profile>
</profiles>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<!-- for hot reload of the web application-->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.1.3.v20140225</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>display-dependency-updates</goal>
<goal>display-plugin-updates</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>3.1</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>${project.build.directory}/generated-sources/appengine-endpoints</directory>
<!-- the list has a default value of ** -->
<includes>
<include>WEB-INF/*.discovery</include>
<include>WEB-INF/*.api</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.9.30</version>
<configuration>
<enableJarClasses>false</enableJarClasses>
<!-- Comment in the below snippet to bind to all IPs instead of just localhost -->
<!-- address>0.0.0.0</address>
<port>8080</port -->
<!-- Comment in the below snippet to enable local debugging with a remove debugger
like those included with Eclipse or IntelliJ -->
<!-- jvmFlags>
<jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag>
</jvmFlags -->
</configuration>
<executions>
<execution>
<goals>
<goal>endpoints_get_discovery_doc</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

Let me know if you see any thing fishy here and which is breaking it.

Rohit
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsub...@googlegroups.com.

Rohit Nigam

unread,
Feb 29, 2016, 8:13:33 PM2/29/16
to Google Cloud Pub/Sub Discussions, tanu...@gmail.com
            <groupId>com.google.inject.extensions</groupId<span st

Alex Mordkovich

unread,
Feb 29, 2016, 8:18:12 PM2/29/16
to Rohit Nigam, Google Cloud Pub/Sub Discussions
There is no %7F anywhere in the logs (AFAICT) or in requests; there is only %2F, which is an encoded slash ('/'). Rohit, please explain or provide the code that is used to set the variable subscriberName. Are you sure it's not being modified concurrently by another thread?

To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/f37f1677-97c8-4664-8f6d-61b6383709a5%40googlegroups.com.

Rohit Nigam

unread,
Feb 29, 2016, 8:38:52 PM2/29/16
to Google Cloud Pub/Sub Discussions, tanu...@gmail.com
I don't know where the %7F is coming from , i am using API explorer to send the request and i see this in GAE logs.

17:34:18.666
com.example.helloendpoints.Greetings registerEnpoint: Creating projects/x/subscriptions/test_sub
17:34:18.806
com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backend method com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 NOT_FOUND <!DOCTYPE html> <html lang=en> <meta charset=utf-8> <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"> <title>Error 404 (Not Found)!!1</title> <style> *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px} </style> <a href=//www.google.com/><span id=logo aria-label=Google></span></a> <p><b>404.</b> <ins>That’s an error.</ins> <p>The requested URL <code>/v1/projects%2Fx%2Fsubscriptions%2Ftest_sub</code> was not found on this server. <ins>That’s all we know.</ins> at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321) at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1045)


Rohit
...

Rohit Nigam

unread,
Feb 29, 2016, 8:41:34 PM2/29/16
to Google Cloud Pub/Sub Discussions, tanu...@gmail.com
Here is the code :--

private String getFullyQualifiedResourceName(ResourceType resourceType, String project, String resource) {
return String.format("projects/%s/%s/%s", project.trim(), resourceType.collectionName, resource.trim());
}

Rohit

On Monday, February 29, 2016 at 5:18:12 PM UTC-8, Alex Mordkovich wrote:
...

Takashi Matsuo

unread,
Mar 2, 2016, 1:32:50 PM3/2/16
to Rohit Nigam, Google Cloud Pub/Sub Discussions

Hi Rohit,

Yeah, my bad it's %2F (encoded slash).

Your original code doesn't include the call for getFullyQualifiedResourceName method you showed.
Where do you call getFullyQualifiedResourceName and how do you set the value of `subscriberName` variable?

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.

rni...@slb.com

unread,
Mar 4, 2016, 5:33:56 PM3/4/16
to Google Cloud Pub/Sub Discussions, tanu...@gmail.com
Hi Takashi
This the code 

String subscriberName = getFullyQualifiedResourceName(
"subscriptions", projectName.trim(), topic.trim() + "_sub").trim();

PushConfig pushConfig = new PushConfig().setPushEndpoint(url);


Subscription subscription = new Subscription()
                    // The name of the topic from which this subscription
// receives messages
.setTopic(topicName)
//Acknowledgement deadline in second
.setAckDeadlineSeconds(60)
// Only needed if you are using push delivery
.setPushConfig(pushConfig);
LOG.info("after getting subscription");
LOG.info("Creating " + subscriberName);
LOG.info("base url " + pubsub.getBaseUrl() + " root url " + pubsub.getRootUrl());

Subscription newSubscription = pubsub.projects().subscriptions().create(
subscriberName, subscription)
.execute();
...

Nicholas Gelinas

unread,
Mar 7, 2016, 1:48:24 PM3/7/16
to Google Cloud Pub/Sub Discussions
I too cannot yet reproduce exactly this issue with the code provided.
  • What is the value of subscriberName right after invoking getFullyQualifiedResourceName? As String.format does not perform any URL encoding, this may be useful to determine when '/' becomes '%2F'.
  • Is getFullyQualifiedResourceName overloaded elsewhere in your code accepting a String as the first parameter? The example you provide passes "subscriptions" as a first parameter where getFullyQualifiedResourceName seems to expect ResourceType (though I would assume ResourceType.collectionName would return "subscriptions" if it were a subscription ResourceType)
  • What is the value of subscriptionName immediately before invoking pubsub.projects().subscriptions().create(subscriberName, subscription)? The documentation for said method reveals what characters are accepted as a name but not what method is used to safely encode the name.
  • The log of the create() API call should reveal what the value of subscriberName becomes once URL-encoded. Can you also include that here?

rni...@slb.com

unread,
Mar 7, 2016, 3:11:01 PM3/7/16
to Google Cloud Pub/Sub Discussions
Hi
The subscriber name looks like

projects/project_name/subscriptions/subscriber_name

The funny part is i am able to run the same code in a different intellij project which does not include GAE end points JARS but when i try to run it in my current project which include endpoint jars it fails. is there a correlation here ?

Rohit

Nicholas Gelinas

unread,
Mar 11, 2016, 4:53:50 PM3/11/16
to Google Cloud Pub/Sub Discussions
Is it simply including the Endpoints JAR that makes this difference or is there some particular usage of it that causes the PubSub call to fail?


On Monday, February 29, 2016 at 5:28:37 PM UTC-5, Rohit Nigam wrote:
Reply all
Reply to author
Forward
0 new messages