I found a strange error after migration to new hosting.
We have moved our server from Moscow and London.
I added a new IP to Google Developers Console (178.79.158.44).
After that, a part of the IPA worked good:
1) "https://www.googleapis.com/oauth2/v1/userinfo" is working good
2) But "https://www.googleapis.com/calendar/v3/calendars/$calendar_id/events" - always return "403 Forbidden" error
What am I doing wrong?
On the old server in Moscow, everything is still working well.
My project ID "rapid-arbor-522"
I solved the problem.
The fact was that the new server has been configured and IPv4 and IPv6.
And apparently, some requests went through IPv6 that has not been configured in the console.
Once I disabled ipv6 (sysctl -w net.ipv6.conf.all.disable_ipv6 = 1) it worked =)
Related
I'm trying to get a local api and local website(consumer of api) to work together for last two days but no joy.
Local Api: apishop.test
Local Consumer: frontendflex.test
When i connect to a live api (like fakestoreapi.com) it works fine from Local Consumer website. Both my own local api and the fakestoreapi produce valid json on screen
I have tried various ways to communicate with the local api that dont work.
$res=json_decode(file_get_contents('http://apishop.test/products/' . $request->product)
error..
file_get_contents(https://apishop.test/products/2): Failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
$res = Http::acceptJson()->get('http://apishop.test/products/' . $request->product);
ErrorException
Undefined property: Illuminate\Http\Client\Response::$title (View: C:\xampp\htdocs\frontendflex\resources\views\shop\product.blade.php). This makes sense beacause if I dd($res) it is 500 internal server error like file_get_contents()
So to curl...
curl_setopt($handle, CURLOPT_URL, 'http://apishop.test/products/2');
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']??null);
curl_setopt($handle, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
//$res= json_decode(curl_exec($handle), true); //Attempt to read property "title" on null
//$res= curl_exec($handle); //Attempt to read property "title" on string
curl_close($handle);
But when I dd($res) it spews out crazy error data at which the top is....
Illuminate\Database\QueryException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'frontendflex.products' doesn't exist (SQL: select * from products where products.id = 2 limit 1)
http://apishop.test/products/2
There is NO products table here, it is in api website. I'm running frontendflex.test here. So getting more curious, I deliberately caused an error in api website code and it picked it up on the consumer website frontendflex.test. What's going on here ?? Both websites are totally separated but under xampp. Head-banging for two days now. Any help appreciated
Well in desperation i created a brand new clean laravel project, just one controller and one route to access the api and it worked. So, I need to drill down as to what is happening with the other site. Mis-config somewhere.
Edit:
I discovered that for some reason if i access the consumer website (frontendflex.test) by php artisan:serve (http://127.0.0.1:8000/doda)it accesses the api site apishop.test no problem. Weird, but not wonderful!! Anybody out there that can shine a light on this?
Edit: Discovered a workaround.
Change port for consumer site to http://frontendflex.test:8080/doda
NameVirtualHost *:8080
<VirtualHost 127.0.0.1:8080>
DocumentRoot "C:/xampp/htdocs/frontendflex/public"
ServerName frontendflex.test
</VirtualHost>
Changed to this in apache vhosts file
This works but i would like to know why other way does not work.
Hope this helps someone somewhere someday :)
the gmail smtp-relay works fine using the sync driver, but if we queue the email we this error. cleared config, cache, & restarted queue workers. tested in prod and dev, same results
[2021-01-24 20:04:22] production.ERROR: Expected response code 250 but got an empty response {"exception":"[object] (Swift_TransportException(code: 0): Expected response code 250 but got an empty response at /home/****/****/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:448)
were wondering is this because of serialization and something is not making it through that process???
using latest stable release of laravel >8.0. gmail smtp is authenticating just fine, per why the sync driver sends emails easily. maybe there needs to be a timeout on the queue jobs so they dont barrage gmail so quickly? also our code works fine using sendgrid for example as the smtp relay. thanks.
See https://laracasts.com/discuss/channels/laravel/laravel-swift-mailer-exception-expected-response-code-250-but-got-an-empty-response-using-gmail-smtp-relay-database-queue-driver
Update your AppServiceProvider.php
add this inside boot();
// Fix for SwiftMailer Service;
$_SERVER["SERVER_NAME"] = "your.domain.name";
For users of smtp-relay.gmail.com, if you use localhost/127.0.0.1 as domain during developments, you probably need to change the domain name to use in EHLO command to begin the transaction. I solved this by adding &local_domain=dev.mydomain.tld at the and of my DSN.
smtp://smtp-relay.gmail.com:587?encryption=tls&local_domain=dev.mydomain.tld&...
For SwiftMailer Symfony bundle (since 2.4.0), you can set the local_domain config parameter:
// config/packages/dev/swiftmailer.yaml
swiftmailer:
...
local_domain: dev.mydomain.tld
Explanation for the 2 previous Answers
if $_SERVER["SERVER_NAME"] is the solution:
When you are using cron
The reason is that $_SERVER["SERVER_NAME"] is null when cron is executed. $_SERVER["SERVER_NAME"] is usually only defined for http access.
Example implementation (laravel):
if (!isset($_SERVER['SERVER_NAME'])) {
$url = config('env.APP_URL');
$domain = mb_ereg_replace("http(s)? ://", "", $url);
$domainParts = explode('/', $domain);
ini_set('server_name', count($domainParts) > 0 ? $domainParts[0] : $domain)
}
References :
Cron Job $_SERVER issue
https://github.com/swiftmailer/swiftmailer/issues/992
if 'local_domain' is the solution
When you have a mailhost setting of MAIL_HOST=smtp-relay.gmail.com in your laravel project
The reason is that if local_domain' is not set, the protocol for mail communication with Gmail will be EHLO [127.0.0.1]` and the communication will be disconnected.
By the way, I used gmail->gmail alias and did not need relay in the first place, so I solved the problem by setting MAIL_HOST=smtp.gmail.com.
References:
https://blog.trippyboy.com/2021/laravel/laravel-expected-response-code-250-but-got-an-empty-response/
I had to deal with both of them because of cron messaging and MAIL_HOST=smtp-relay.gmail.com in my environment.
I hope this information will help you.
I have a simple MVC web application where javascript code sends ajax requests to the controller and the controller sends back responses.
I built the app 2 years ago and everything used to work fine. Now I tried to run the app again locally and met with the following problem:
whenever an Ajax request is sent from the frontend to the controller (running on localhost), the localhost refuses to connect and I get an ERR_CONNECTION_REFUSED message in (chrome's) javascript-console. (In Safari's javascript-console I get the following error message: "Failed to load resource: Could not connect to the server.")
I'm running the app using NetBeans 11.2. My NetBeans IDE uses GlassFish as server:
I removed the Glassfish server from NetBeans IDE, deleted its folder in my home directory and then added the Glassfish server again in my NetBeans IDE (which also entailed downloading the the newest version of the Glassfish server).
Still, the server refuses to accept any requests from the frontend.
I also tried using Payara Server (version 5.193). That didn't make a difference either.
The frontend itself looks fine at first glance by the way. That is, going to http://localhost:8080/myapp loads the frontend of the app. However, any dynamic features of the app don't work because the server refuses to accept any Ajax requests coming from the frontend (and initiated through mouse clicks).
How can I fix this?
I think I found the reason for the problem:
In my javascript-file I have the following line of code:
var url = "http://localhost:8080/myapp/Controller";
The variable "url" is passed to all the AJAX requests sent to localhost.
But here is the crazy thing: the AJAX requests are not sent to "http://localhost:8080/myapp/Controller" but to "http://localhost:8081/myapp/Controller" !!!!!
What the hell is going on here?!
Did you use port 8081 before and then changed the variable "url" to the new port 8080? In this case, maybe the variable is still set to the old value in the cache. Restart your computer and see whether this fixes the problem.
If the value of the attribute http-listener is localhost, it will refuse the connection external connection.
You can verify using its value using the command
asadmin> get server-config.network-config.network-listeners.network-listener.http-listener-1.*
Information similar to the following should returned:
server.http-service.http-listener.http-listener-1.acceptor-threads = 1
server.http-service.http-listener.http-listener-1.address = 0.0.0.0
server.http-service.http-listener.http-listener-1.blocking-enabled = false
server.http-service.http-listener.http-listener-1.default-virtual-server = server
server.http-service.http-listener.http-listener-1.enabled = true
server.http-service.http-listener.http-listener-1.external-port =
server.http-service.http-listener.http-listener-1.family = inet
server.http-service.http-listener.http-listener-1.id = http-listener-1
server.http-service.http-listener.http-listener-1.port = 8080
server.http-service.http-listener.http-listener-1.redirect-port =
server.http-service.http-listener.http-listener-1.security-enabled = false
server.http-service.http-listener.http-listener-1.server-name =
server.http-service.http-listener.http-listener-1.xpowered-by = true
Modify an attribute by using the set subcommand.
This example sets the address attribute of http-listener-1 to 0.0.0.0:
asadmin> set server.http-service.http-listener.http-listener-1.address = 0.0.0.0
Reference:
https://docs.oracle.com/cd/E19798-01/821-1751/ablaq/index.html
I have to refresh an old webapp and i'm facing a problem i can't find...
Old situation :
webapp (Java6, wicket) on Weblogic 10.3, external access via URL rewrite by IIS
everything OK
New situation :
refreshed webapp on WL 12.2, IIS unchanged.
Results : Inside URLs : everything OK
Outside URLs : HTTP 200 OK, but all pages HTTP 302 (redirections) fails
browser receive 503 (unavailable) after a while.
I looked at the logs :
WL12 : process OK, response 302 found, location:inside URL
IIS : found code 400
I looked at [Oracle docs][1], i saw that they added CSRF protection, i believed it could be that, i disabled it, but nothing changed.
Any idea ?
Thanks in advance.
[1]: https://docs.oracle.com/middleware/12213/wls/WBAPP/weblogic_xml.htm#WBAPP-GUID-E3A9B2FC-E098-43B1-ACFF-4A457D6062DE search for "referer-validation"
Forget that.
The WL12 was installed on an "end of life" server running HP Unix.
I deployed the same app on WL12 on redhat, it worked as intended.
I'm trying to send emails from Joomla! 1.5.9, but keep getting this error message: PHPMAILER_RECIPIENTS_FAILEDrecipient_name<recipient_email>
A few more facts:
It's a WAMP server (joomla 1.5.9, PHP 5.2.8)
Validation emails are sent with no problem at all
Joomla! is set to use SMTP
The IIS SMTP service is used (though I'm not 100% sure about it's configuration)
The diagnostics tool smtpdiag shows no problem when checking the sender/recipient
Any ideas?
Thanks,
Omer.
Perhaps this has already been answered before # Joomla forums itself.
http://forum.joomla.org/viewtopic.php?f=431&t=272547
I tried many of the solutions given in the link Sukumar provided but none of them worked.
Then I tried to use PHP mail function instead of SMTP and it worked :)
Change the following line in configuration.php in the root folder
var $mailer = 'smtp';
to
var $mailer = 'PHP mail';