RussianInvestments / invest-api-java-sdk

Apache License 2.0
17 stars 3 forks source link

Address family not supported by protocol #23

Open n0rt3l opened 4 months ago

n0rt3l commented 4 months ago

Здравствуйте, подскажите почему так падает, на версии sdk 1.5 всё работает, версии sdk выше 1.5 падают с ошибкой которая привидена ниже. Собираю приложени в единый jar c maven-shade-plugin. Любой вызов после Invest.create(token) падает. OpenJDK 11 (linux).

Exception in thread "main" ru.tinkoff.piapi.core.exception.ApiRuntimeException: unknown error at ru.tinkoff.piapi.core.utils.Helpers.apiRuntimeException(Helpers.java:55) at ru.tinkoff.piapi.core.utils.Helpers.unaryCall(Helpers.java:45) at ru.tinkoff.piapi.core.InstrumentsService.getSharesSync(InstrumentsService.java:531) at ru.tinkoff.piapi.core.InstrumentsService.getTradableSharesSync(InstrumentsService.java:563) at com.mymy.App.monitor(App.java:1201) at com.mymy.App.main(App.java:97) Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE: io exception at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:275) at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:256) at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:169) at ru.tinkoff.piapi.contract.v1.InstrumentsServiceGrpc$InstrumentsServiceBlockingStub.shares(InstrumentsServiceGrpc.java:2011) at ru.tinkoff.piapi.core.InstrumentsService.lambda$getSharesSync$30(InstrumentsService.java:531) at ru.tinkoff.piapi.core.utils.Helpers.unaryCall(Helpers.java:43) ... 4 more Caused by: io.grpc.netty.shaded.io.netty.channel.AbstractChannel$AnnotatedConnectException: connect(..) failed: Address family not supported by protocol: /invest-public-api.tinkoff.ru:443 Caused by: java.net.ConnectException: connect(..) failed: Address family not supported by protocol at io.grpc.netty.shaded.io.netty.channel.unix.Errors.newConnectException0(Errors.java:155) at io.grpc.netty.shaded.io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:128) at io.grpc.netty.shaded.io.netty.channel.unix.Socket.connect(Socket.java:351) at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel.doConnect0(AbstractEpollChannel.java:773) at io.grpc.netty.shaded.io.netty.channel.epoll.EpollSocketChannel.doConnect0(EpollSocketChannel.java:144) at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel.doConnect(AbstractEpollChannel.java:758) at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.connect(AbstractEpollChannel.java:600) at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.connect(DefaultChannelPipeline.java:1342) at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:653) at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:632) at io.grpc.netty.shaded.io.netty.channel.ChannelDuplexHandler.connect(ChannelDuplexHandler.java:54) at io.grpc.netty.shaded.io.grpc.netty.WriteBufferingAndExceptionHandler.connect(WriteBufferingAndExceptionHandler.java:157) at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:655) at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.access$1000(AbstractChannelHandlerContext.java:61) at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext$9.run(AbstractChannelHandlerContext.java:637) at io.grpc.netty.shaded.io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) at io.grpc.netty.shaded.io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:406) at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:829)

n0rt3l commented 4 months ago

Решено. Проблема была в том что зависимость grpc-java плохо упаковывается maven-shade-plugin. И ломается резолвер. Нужно добавить трансформеры приведнные ниже. Issue на grpc-java - https://github.com/grpc/grpc-java/issues/10861

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>

                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.your.MainClass</mainClass>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                            </transformers>
                        </configuration>

                    </execution>
                </executions>
            </plugin>