开发者社区> 问答> 正文

支付宝开放平台消息服务的WebSocket方式接入时,如果接口加签方式设置公钥证书时应该怎么接入

使用公钥证书加签时,按照文档提供的方法报错,没法接入,想请问一下应该用什么方式接入?是使用java的

接入代码如下:

// 目标蚂蚁金服服务端地址,线上环境为 openchannel.alipay.com
		String serverHost = "openchannel.alipay.com";
		// 数据签名方式,请与应用设置的默认签名方式保持一致
		String signType = "RSA2";
		
		// 支付宝公钥
		String alipayPublicKey = AlipaySignature.getAlipayPublicKey(ALIPAY_CERT_PATH);
		
		// 获取client对象,一个appId对应一个实例
		AlipayMsgClient client = AlipayMsgClient.getInstance(APP_ID);
		client.setConnector(serverHost);
		client.setSecurityConfig(signType, APP_PRIVATE_KEY, alipayPublicKey);
		client.setBizThreadPoolCoreSize(16);
		client.setBizThreadPoolMaxSize(32);
		client.setMessageHandler(new MsgHandler() {

		    public void onMessage(String msgApi, String msgId, String bizContent) {
		        System.out.println("receive message. msgApi:" + msgApi + " msgId:" + msgId + " bizContent:" + bizContent);
		    }
		});
		client.connect();

返回异常如下:

2019-10-14 20:42:39.558 - sdk.biz.err java.lang.RuntimeException: register response code means fail! {"msg":"sigsecretkeynotconfigured","code":"112031005"}
java.lang.RuntimeException: register response code means fail! {"msg":"sigsecretkeynotconfigured","code":"112031005"}
	at com.alipay.api.msg.AlipayMsgClient.parseRegResp(AlipayMsgClient.java:439)
	at com.alipay.api.msg.AlipayMsgClient.register(AlipayMsgClient.java:387)
	at com.alipay.api.msg.AlipayMsgClient.doConnect(AlipayMsgClient.java:141)
	at com.alipay.api.msg.AlipayMsgClient.access$300(AlipayMsgClient.java:39)
	at com.alipay.api.msg.AlipayMsgClient$2.run(AlipayMsgClient.java:109)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

展开
收起
游客fppasy53lzeg4 2019-10-14 20:43:16 2856 0
0 条回答
写回答
取消 提交回答
来源圈子
更多
收录在圈子:
问答排行榜
最热
最新

相关电子书

更多
阿里云通信战略新品发布 ——国际/港澳台消息服务 立即下载
阿里云通信战略新品发布—国际/港澳台消息服务 立即下载
消息服务在Serverless中的应用 立即下载