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

error code : 1109, error msg : 请求参数非法,请检查 t : 1692034588289 #42

Open
leandromsales opened this issue Aug 14, 2023 · 2 comments

Comments

@leandromsales
Copy link

leandromsales commented Aug 14, 2023

考虑以下请求:

POST /v1.0/devices/DEVICE_ID_HERE/commands HTTP/1.1
Host: openapi.tuyaus.com
client_id: ********
access_token: ********
sign: ********
t: 1692034308756
sign_method: HMAC-SHA256
Content-Type: application/json
Content-Length: 140

{
  "commands": [
    {
      "code": "switch_1",
      "value": true
    },
    {
      "code": "switch_2",
      "value": true
    }
  ]
}

如果我使用 postman 或 curl 执行此操作,一切正常,但使用 tuya-spring-boot-starter 我收到以下错误:

error code : 1109, error msg : 请求参数非法,请检查 t : 1692034588289

为什么会发生这种情况?

这是请求的代码:

public interface TuyaClient {

    @POST("/v1.0/devices/{device_id}/commands")
    Boolean commands(@Path("device_id") String deviceId, @Body String commandRequest);

}

[...]

public void switchDevice(String deviceId) {
    CommandRequest commandRequest = new CommandRequest();
    commandRequest.addCommand(new Command("switch_1", Boolean.TRUE));
    commandRequest.addCommand(new Command("switch_2", Boolean.TRUE));
     try {
         tuyaClient.commands(deviceId, JSON.toJSONString(commandRequest));

    } catch (JSONException | ConnectorResultException e) {
        e.printStackTrace();
    }
}

这是堆栈跟踪:

com.tuya.connector.api.exceptions.ConnectorResultException: error code : 1109, error msg : 请求参数非法,请检查 t : 1692034588289
	at com.tuya.connector.api.exceptions.ExceptionFactory.ofCode(ExceptionFactory.java:33)
	at com.tuya.connector.api.core.delegate.RetrofitDelegate.execute(RetrofitDelegate.java:115)
	at com.tuya.connector.api.core.ConnectorProxy.invoke(ConnectorProxy.java:50)
	at jdk.proxy4/jdk.proxy4.$Proxy142.commands(Unknown Source)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at com.tuya.connector.api.plugin.Invocation.proceed(Invocation.java:29)
	at com.tuya.connector.api.error.ErrorProcessorInterceptor.intercept(ErrorProcessorInterceptor.java:31)
	at com.tuya.connector.api.plugin.Plugin.invoke(Plugin.java:26)
	at jdk.proxy4/jdk.proxy4.$Proxy142.commands(Unknown Source)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at com.tuya.connector.api.plugin.Invocation.proceed(Invocation.java:29)
	at com.tuya.connector.api.context.ContextInterceptor.intercept(ContextInterceptor.java:30)
	at com.tuya.connector.api.plugin.Plugin.invoke(Plugin.java:26)
	at jdk.proxy4/jdk.proxy4.$Proxy142.commands(Unknown Source)
	at mypackage.platform.service.devices.DeviceService.switchDevice(DeviceService.java:38)
	at mypackage.platform.service.devices.DeviceController.switchDevice(DeviceController.java:41)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:914)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:590)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
	at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:109)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:166)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:676)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:894)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1740)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:1623)

Result(code=1109,msg=请求参数非法,请检查,t=1692034588289) is not successful for requeset: mypackage.clients.tuya.TuyaClient.commands(java.lang.String, java.lang.String), args: (DEVICE_ID_HERE, {"commands":[{"code":"switch_1","value":true},{"code":"switch_2","value":true}]})

我也尝试过,但也没有运气:

@POST("/v1.0/iot-03/devices/{device_id}/commands")
Boolean command(@Path("device_id") String deviceId, @Body Map<String, Object> commands);

有解决这个问题的线索吗?

@leandromsales
Copy link
Author

leandromsales commented Aug 16, 2023

FYI, I have tried with 1.3.2 and still the same issue. Anyone to help me on this?

@leandromsales
Copy link
Author

Why nobody in this project address this issue yet? Is there someone looking at this?

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

1 participant