GCM Configuration

本文介绍如何为Android项目启用Google Cloud Messaging (GCM) 服务,包括查找Google项目编号、启用GCM API及获取API密钥的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GCM Configuration

Here’s what you have to do in order to enable the GCM service for your Android project


Locate your Google Project Number


The Project Number is automatically assigned by the Google Developers Console when you create a project. You can find the Project Number in the “Dashboard” tab of the Google API console.

Here, 852741519435 is the Project Number you enter in the app. Don’t confuse it with Project ID, which is a completely different identifier & is used only within Developers Console!

Enable GCM and Get Credentials


1. In the main Google APIs Console page, select API Manager.

2. Locate and click Google Cloud Messaging in Mobile APIs section.

3. Enable API.

Now you need to create the API key.

4. Go to the Credential section of the console, click "Create Credentials" and select API key

5. Select a server key or a browser key. The advantage to using a server key is that it allows you to whitelist IP addresses.

6. Press “Create”.

7. Here’s the API Key you will need to configure your application in Pushwoosh Control Panel.

Go to the Pushwoosh Control Panel

8. In your application click on Android->Edit to change the configuration for Android application.

9. Copy your API Key to the field provided.

That’s it! Easy, isn’t it?

MismatchSenderID error

If you receive “Sender Mismatch ID” error when using “Server Key” please try using “Browser Key”

2025-07-03T14:27:05.799533225+08:00 stdout F 06:27:05.799 [main] DEBUG io.netty.handler.ssl.OpenSsl - Supported protocols (OpenSSL): [SSLv2Hello, TLSv1, TLSv1.1, TLSv1.2, TLSv1.3] 2025-07-03T14:27:05.799601063+08:00 stdout F 06:27:05.799 [main] DEBUG io.netty.handler.ssl.OpenSsl - Default cipher suites (OpenSSL): [TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384] 2025-07-03T14:27:05.940850208+08:00 stdout F Exception (org.apache.cassandra.exceptions.ConfigurationException) encountered during startup: Invalid yaml. Those properties [thrift_prepared_statements_cache_size_mb] are not valid 2025-07-03T14:27:05.940921257+08:00 stderr F Invalid yaml. Those properties [thrift_prepared_statements_cache_size_mb] are not valid 2025-07-03T14:27:05.941107882+08:00 stdout F 06:27:05.940 [main] ERROR org.apache.cassandra.service.CassandraDaemon - Exception encountered during startup: Invalid yaml. Those properties [thrift_prepared_statements_cache_size_mb] are not valid ^C [root@node1 cassandra]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 21490d5a5e68 docker.io/library/cassandra:4.0 cassandra -f 2 minutes ago Exited (3) 2 minutes ago 0.0.0.0:9042->9042/tcp cassandra 这是日志为什么启动失败
07-04
<think>我们遇到了一个新的错误:Cassandra containerstartup failed: Invalidyamlproperty thrift_prepared_statements_cache_size_mb这个错误表明在Cassandra的配置文件中存在一个无效的属性名。在Cassandra4.0中,一些配置项可能已经被移除或重命名。根据错误信息,`thrift_prepared_statements_cache_size_mb`这个属性在yaml配置中是无效的。在Cassandra4.0中,Thrift协议已经被移除了(从3.0开始就废弃了,4.0完全移除)。因此,与Thrift相关的配置项都不再有效。解决方案:1.检查配置文件(位于宿主机目录/opt/janusgraph/conf/cassandra下的yaml文件,通常是cassandra.yaml)中是否包含`thrift_prepared_statements_cache_size_mb`这个配置项。2.删除或注释掉这个配置项。步骤:1.打开配置文件:/opt/janusgraph/conf/cassandra/cassandra.yaml2.搜索`thrift_prepared_statements_cache_size_mb`,找到该行。3.在该行前面加上#号注释掉,或者直接删除该行。然后重新启动容器。注意:由于我们使用了卷挂载,修改宿主机上的配置文件后,容器内的配置会自动更新。另外,由于之前我们调整了权限和SELinux标签,请确保在重新启动之前已经按照之前的建议调整了权限和标签(使用:z标签以及正确的目录所有权)。重新启动容器的步骤:1.如果容器已经存在,先删除:podman stopcassandrapodmanrm cassandra2.重新运行创建容器的命令(注意:我们这里使用:z标签,并且已经调整了目录权限):podmanrun -d \--name cassandra \-p9042:9042 \-v /opt/janusgraph/conf/cassandra:/etc/cassandra:z\-v/home/iaas/janusgraph-full-0.6.3/cassandra/lib:/usr/share/cassandra/lib:z\-eCASSANDRA_CONF=/etc/cassandra \-e CLASSPATH=/usr/share/cassandra/lib/* \-e CASSANDRA_AUTHENTICATOR=PasswordAuthenticator\docker.io/library/cassandra:4.0如果问题依旧,请检查配置文件中是否还有其他被废弃的属性。可以参照Cassandra4.0的官方文档来检查配置项。另外,JanusGraph的Cassandra配置可能是为旧版本Cassandra设计的,所以需要更新配置以兼容Cassandra4.0。参考:Cassandra4.0的配置文档:https://cassandra.apache.org/doc/4.0/cassandra/configuration/常见被移除的配置项(与Thrift相关):-thrift_prepared_statements_cache_size_mb- thrift_max_message_length_in_mb- start_rpc- rpc_port- rpc_keepalive-...等等在Cassandra4.0中,应该使用CQL协议(通过9042端口),而不是Thrift。因此,在配置文件中,确保以下与Thrift相关的配置项被注释或删除,并且不要启用Thrift(即`start_rpc:false`,但最好直接删除这些配置)。同时,确保配置文件中的其他设置符合Cassandra4.0的要求。如果问题仍然存在,可以尝试使用Cassandra3.11的镜像(如果JanusGraph版本对4.0支持不好),但建议更新JanusGraph的配置。注意:JanusGraph0.6.3官方支持的Cassandra版本是3.11,但可能兼容4.0。如果遇到其他问题,可能需要升级JanusGraph版本或调整配置。最后,如果调整配置后启动成功,记得创建用户(因为启用了PasswordAuthenticator):podman exec-itcassandracqlsh -u cassandra -p cassandra#然后创建新用户(例如:janusgraph)并授权,或者修改默认用户密码。默认的Cassandra超级用户是cassandra,密码也是cassandra(如果使用默认配置)。在生产环境中请务必修改。创建用户示例:CREATE ROLE janusgraphWITH PASSWORD ='password' ANDLOGIN= true;GRANTALL PERMISSIONS ONALL KEYSPACES TOjanusgraph;或者,可以在配置文件中设置初始用户(通过环境变量):-e CASSANDRA_SUPERUSER=janusgraph -e CASSANDRA_SUPERUSER_PASSWORD=password但注意,官方镜像可能不支持这个环境变量,需要查看镜像文档。因此,我们可能需要手动创建用户。综上所述,主要步骤是修改配置文件,移除无效的Thrift配置项。</think>### 解决 Cassandra 容器启动失败:无效 YAML 属性错误 #### 问题分析 错误信息 `Invalid yaml property thrift_prepared_statements_cache_size_mb` 表明 Cassandra 4.0 不再支持 Thrift 协议相关的配置项。这是因为: 1. **Thrift 协议已弃用**:Cassandra 4.0 完全移除了 Thrift API(从 3.0 开始已废弃)[^1] 2. **配置兼容性问题**:您的配置文件可能基于旧版 Cassandra(≤3.x) 3. **属性冲突**:`thrift_prepared_statements_cache_size_mb` 是 Thrift 特有的配置项,在 4.0 中无效 --- #### 解决方案步骤 ##### 1. 修改 Cassandra 配置文件 ```bash # 编辑配置文件 sudo vi /opt/janusgraph/conf/cassandra/cassandra.yaml # 搜索并删除以下无效属性 thrift_prepared_statements_cache_size_mb: # 删除此行 thrift_framed_transport_size_in_mb: # 删除此行 start_rpc: true # 必须改为 false 或删除 rpc_port: 9160 # 必须删除(Thrift 端口) ``` ##### 2. 更新关键配置项 ```diff # 必需配置变更 + start_native_transport: true # 启用 CQL 协议(默认端口9042) + native_transport_port: 9042 # 明确指定 CQL 端口 - start_rpc: false # 禁用 Thrift RPC(必须设置) ``` ##### 3. 验证配置文件语法 ```bash # 检查 YAML 语法 podman run --rm -it \ -v /opt/janusgraph/conf/cassandra:/etc/cassandra:z \ cassandra:4.0 \ bash -c "cassandra -f -Dcassandra.config=/etc/cassandra/cassandra.yaml --validate" ``` 正常输出应显示:`Checking YAML configuration: OK` ##### 4. 重新启动容器 ```bash podman rm -f cassandra # 删除旧容器 podman run -d \ --name cassandra \ -p 9042:9042 \ -v /opt/janusgraph/conf/cassandra:/etc/cassandra:z \ -v /home/iaas/janusgraph-full-0.6.3/cassandra/lib:/usr/share/cassandra/lib:z \ -e CASSANDRA_CONF=/etc/cassandra \ -e CLASSPATH=/usr/share/cassandra/lib/* \ -e CASSANDRA_AUTHENTICATOR=PasswordAuthenticator \ docker.io/library/cassandra:4.0 ``` ##### 5. 验证服务状态 ```bash podman logs cassandra | grep "Starting listening for CQL clients" ``` 正常输出:`Starting listening for CQL clients on /0.0.0.0:9042` --- #### 配置变更说明 | 旧配置项 | 状态 | 替代方案 | |---------|------|---------| | `thrift_prepared_statements_cache_size_mb` | ❌ 已移除 | 无替代(Thrift 已弃用) | | `start_rpc` | ❌ 已弃用 | 使用 `start_native_transport` | | `rpc_port` | ❌ 已移除 | 使用 `native_transport_port` | | `thrift_framed_transport_size_in_mb` | ❌ 已移除 | 无替代 | > **注意**:JanusGraph 0.6.3 官方支持 Cassandra 3.11,若需完全兼容建议: > ```bash > podman run ... docker.io/library/cassandra:3.11.14 > ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值