AWS MSK - Callout timeout exception - kotlin

I have built a custom Kafka source connector for MSK and it works up to the point the callout happens. It throws a timeout error once it reaches that stage. I have configure the internet access using this tutorial https://docs.aws.amazon.com/msk/latest/developerguide/msk-connect-internet-access.html but it still fails. The custom config source works fine though with AWS Secrets. Below is a sample of the callout and the error I am hitting.
val url = URL("$sforceUrl/sforce/api/salesforce?orgId=$orgId")
val conn = url.openConnection() as HttpURLConnection
conn.setRequestProperty("Authorization", "Bearer $sforceAuthToken")
conn.setRequestProperty("Content-Type", "application/json")
conn.requestMethod = "GET"
val `in` = BufferedReader(InputStreamReader(conn.inputStream))
var output: String?
val response = StringBuilder()
while (`in`.readLine().also { output = it } != null) {
response.append(output)
}
`in`.close()
[Worker-0980ff7f2e26f67dc] java.lang.RuntimeException: java.lang.RuntimeException: java.net.ConnectException: Connection timed out (Connection timed out)

Related

STATUS_ACCESS_DENIED (0xc0000022): Authentication failed when accessing AWS S3 SMB share with SMB_3_1_1 in Java SMB client

Getting authentication failed while trying to connect to the AWS S3 SMB path using SMB_3_1_1 of com.hierynomus.smbj client 0.11.5
Public.
Getting below error:
STATUS_ACCESS_DENIED (0xc0000022): Authentication failed for '[username]' using com.hierynomus.smbj.auth.NtlmAuthenticator#4b5189ac
SmbConfig cfg = SmbConfig.builder().withTimeout(120000, TimeUnit.SECONDS)
.withTimeout(120000, TimeUnit.SECONDS)
.withSoTimeout(180000, TimeUnit.SECONDS)
.withMultiProtocolNegotiate(true)
.withSecurityProvider(new JceSecurityProvider(new BouncyCastleProvider()))
.build();
try (SMBClient client = new SMBClient(cfg)){
**connection = client.connect(smbIP);
Session session = connection.authenticate(new AuthenticationContext(smbUserName, smbPassword.toCharArray(), smbDomain));** // from this line getting above exception
DiskShare share = (DiskShare) session.connectShare(smbSharePath);
if(!share.folderExists(destinationFolderName)) {
share.mkdir(destinationFolderName);
}
fileName = destinationFolderName+"\\"+fileName;
f = share.openFile(fileName,
new HashSet<>(Arrays.asList(AccessMask.GENERIC_ALL)),
new HashSet<>(Arrays.asList(FileAttributes.FILE_ATTRIBUTE_NORMAL)),
SMB2ShareAccess.ALL,
SMB2CreateDisposition.FILE_CREATE,
new HashSet<>(Arrays.asList(SMB2CreateOptions.FILE_DIRECTORY_FILE))
);
try(OutputStream os = f.getOutputStream()){
os.write(fileContent);
}catch (Exception e) {
}
}

Outlook AddIn Mobile Issue - not working in mobile whereas same code works for Desktop and web client

I have the bellow error in Microsoft exchange server service, but only on mobiles as same code works for Desktops and web.
ERROR MESSAGE:
System.Net.WebException: The remote server returned an error: (401)
Unauthorized.
at System.Net.HttpWebRequest.GetResponse() at
Microsoft.Exchange.WebServices.Data.EwsHttpWebRequest.Microsoft.Exchange.WebServices.Data.IEwsHttpWebRequest.GetResponse()
in
\REDMOND\EXCHANGE\BUILD\E15\15.00.0913.015\SOURCES\sources\dev\EwsManagedApi\src\EwsManagedApi\Core\EwsHttpWebRequest.cs:line
113 at
Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest
request) in
\REDMOND\EXCHANGE\BUILD\E15\15.00.0913.015\SOURCES\sources\dev\EwsManagedApi\src\EwsManagedApi\Core\Requests\ServiceRequestBase.cs:
line 821The request failed.
The remote server returned an error: (401) Unauthorized.
CODE SNIPPET:
// Create an ExchangeService object, set the credentials and the EWS URL.
ExchangeService exchangeService = new ExchangeService();
exchangeService.Credentials = new OAuthCredentials(attachmentToken);
exchangeService.Url = new Uri(ewsUrl);
exchangeService.UseDefaultCredentials = true;
exchangeService.PreAuthenticate = true;
try
{
var getAttachmentsResponse =exchangeService.GetAttachments(attachmentIds.ToArray(),null,new PropertySet(BasePropertySet.FirstClassProperties,ItemSchema.MimeContent));
}
catch (Exception ex)
{
var errMsg = ex.Message;
var errInnerException = ex.InnerException;
message += "Inner Exception :" + errInnerException;
}

How to init " AWSPricing client " by AWSPricingClientBuilder the latest version sdk?

My task is to get aws procuct pricing data, so I do the things as follows:
set the Environment Variables(AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY)
fill the pom.xml(in Eclipse) with the code:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-pricing</artifactId>
<version>1.11.513</version>
</dependency>
then I code the test method like the code:
public static void testDescribeServices() {
System.out.println("\n\n begin ....");
AWSPricing client = AWSPricingClientBuilder.standard().withRegion("us-east-1").build();
System.out.println("step 0001");
DescribeServicesRequest servicesRequest = new DescribeServicesRequest();
servicesRequest.setServiceCode("AmazonEC2");
DescribeServicesResult result = client.describeServices(servicesRequest);
List<Service> serviceList = result.getServices();
}
run the method testDescribeServices(), the message on the console is like this: (I was disappointed)
begin ....
17:08:21.166 [main] DEBUG com.amazonaws.AmazonWebServiceClient - Internal logging successfully configured to commons logger: true
17:08:21.831 [main] DEBUG com.amazonaws.monitoring.CsmConfigurationProviderChain - Unable to load configuration from com.amazonaws.monitoring.EnvironmentVariableCsmConfigurationProvider#130d63be: Unable to load Client Side Monitoring configurations from environment variables!
17:08:21.831 [main] DEBUG com.amazonaws.monitoring.CsmConfigurationProviderChain - Unable to load configuration from com.amazonaws.monitoring.SystemPropertyCsmConfigurationProvider#42a48628: Unable to load Client Side Monitoring configurations from system properties variables!
17:08:21.831 [java-sdk-http-connection-reaper] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Closing connections idle longer than 60000 MILLISECONDS
17:08:21.839 [main] DEBUG com.amazonaws.monitoring.CsmConfigurationProviderChain - Unable to load configuration from com.amazonaws.monitoring.ProfileCsmConfigurationProvider#689604d9: The 'default' profile does not define all the required properties!
Exception in thread "main" java.lang.NoSuchMethodError: com.amazonaws.client.AwsSyncClientParams.getAdvancedConfig()Lcom/amazonaws/client/builder/AdvancedConfig;
at com.amazonaws.services.pricing.AWSPricingClient.<init>(AWSPricingClient.java:158)
at com.amazonaws.services.pricing.AWSPricingClient.<init>(AWSPricingClient.java:142)
at com.amazonaws.services.pricing.AWSPricingClientBuilder.build(AWSPricingClientBuilder.java:61)
at com.amazonaws.services.pricing.AWSPricingClientBuilder.build(AWSPricingClientBuilder.java:27)
at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
at com.yunion.apps.metadata.TestAWSDemoAPI.testDescribeServices(TestAWSDemoAPI.java:31)
at com.yunion.apps.metadata.TestAWSDemoAPI.main(TestAWSDemoAPI.java:26)
after trying some setting , I make some progress, and the new method is :
public static void testDescribeServices(String accessKey, String secretKey) {
BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(accessKey, secretKey);
AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(basicAWSCredentials);
AWSPricingClientBuilder builder = AWSPricingClientBuilder.standard();
builder.setCredentials(credentialsProvider);
builder.withRegion("us-east-1");
CsmConfigurationProvider csmConfigurationProvider = new EnvironmentVariableCsmConfigurationProvider();
builder.setClientSideMonitoringConfigurationProvider(csmConfigurationProvider);
System.out.println("step 0001");
AWSPricing awsPricing = builder.build();
System.out.println("step 0002");
DescribeServicesRequest servicesRequest = new DescribeServicesRequest();
servicesRequest.setServiceCode("AmazonEC2");
System.out.println("step 0003");
DescribeServicesResult result = awsPricing.describeServices(servicesRequest);
System.out.println("\n\n step 0004");
List<Service> serviceList = result.getServices();
System.out.println("\n\n step 0005");
}
However, the result is
Exception in thread "main" com.amazonaws.services.pricing.model.AWSPricingException: User: arn:aws:iam::285906155448:user/dev1 is not authorized to perform: pricing:DescribeServices **(Service: AWSPricing; Status Code: 400; Error Code: AccessDeniedException; Request ID: 13155463-4198-11e9-8f92-f1f731c320f2)**

Connecting to Amazon ActiveMQ with username & password

I'm trying to connect to ActiveMQ Amazon broker via SSL. My application is written in C#.
Previously, I connected via TCP to localhost ActiveMQ broker, which worked:
using Apache.NMS;
using Apache.NMS.ActiveMQ;
using Apache.NMS.ActiveMQ.Commands;
void Connect()
{
String brokerUri = "activemq:tcp://" + host + ":" + port + "? transport.useLogging=true&wireFormat.maxInactivityDuration=0&userName=myUsername&password=myPassword";
NMSConnectionFactory factory = new NMSConnectionFactory(brokerUri);
IConnection connection = factory.CreateConnection();
connection.Start();
}
To connect to ActiveMQ Amazon broker via SSL, I have modified the code in the following way:
void Connect()
{
String brokerUri = "ssl://" + host + ":" + port + "? transport.useLogging=true&wireFormat.maxInactivityDuration=0&userName=myUsername&password=myPassword";
SslTransportFactory transportFactory = new SslTransportFactory();
Uri uri = new Uri(brokerUri);
ITransport transport = transportFactory.CreateTransport(uri);
transport.Command = Command;
transport.Exception = Exception;
transport.Start();
ConnectionFactory factory = new ConnectionFactory(brokerUri);
IConnection connection = factory.CreateConnection();
Connection con = (Connection)connection;
con.ITransport = transport;
con.Start(); => Here the exception is thrown: User name [null] or password is invalid.
}
private void Exception(ITransport sender, Exception command)
{
}
private void Command(ITransport sender, Command command)
{
}
However, upon starting the connection, User name [null] or password is invalid. Exception is thrown.
Please advise.
You're currently passing user credentials via the URI. However, I don't see any reference to username or password in the URI reference documentation. Also, the fact that the exception indicates the user name is null indicates the user credentials in your URI are simply being ignored.
Instead you should pass the user credentials in the CreateConnection method as documented here, e.g.:
IConnection connection = factory.CreateConnection("myUsername", "myPassword");

WCF net.tcp binding service consume

I have following WCF Client code to consume WCF Service :
static void Main(string[] args)
{
IService1 vService;
NetTcpBinding b = new NetTcpBinding();
b.Security.Mode = SecurityMode.Message;
b.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
EndpointAddress vEndPoint = new EndpointAddress("net.tcp://115.127.1.226/myservice/");
ChannelFactory<IService1> cf = new ChannelFactory<IService1>(b, vEndPoint);
vService = cf.CreateChannel();
try
{
Console.WriteLine("Result from the system " + vService.HellowWorld());
}
catch (Exception ex)
{
Console.WriteLine("Error Occured while connection establish to " + vEndPoint.Uri.ToString());
}
Console.ReadKey();
}
When i run it locally it run successfully.
But When i try to consume my WCF Service remotely it Occurred a exception any one suggest
me how can i solve this problem?
My Exception message is :
Could not connect to net.tcp://115.127.1.226/myservice/. The connection attempt lasted for a time span of 00:00:21.0282028. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
115.127.1.226:808.
try to use
ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;